Class HunspellConversion

java.lang.Object
opennlp.tools.stemmer.hunspell.HunspellConversion

final class HunspellConversion extends Object
Non-recursive longest-match input and output conversions.
  • Field Details

  • Constructor Details

    • HunspellConversion

      private HunspellConversion(List<HunspellConversion.Rule> rules)
      Constructs an immutable table.
      Parameters:
      rules - The conversion definitions.
  • Method Details

    • parse

      static HunspellConversion parse(String[][] lines, String directive) throws IOException
      Parses an affix conversion table and validates the entry count.
      Parameters:
      lines - The affix fields indexed by source line.
      directive - The table name.
      Returns:
      The conversion table.
      Throws:
      IOException - Thrown if the table is malformed.
    • withPhoneticFields

      HunspellConversion withPhoneticFields(Map<String,List<int[]>> entries, Map<int[],List<String>> morphology)
      Adds dictionary transliterations to the replacement table.
      Parameters:
      entries - The dictionary entries and their flags.
      morphology - The fields of each selected entry.
      Returns:
      A table containing REP and ph: replacements.
    • apply

      String apply(String input)
      Replaces the longest matching pattern at each input position without rescanning replacement text.
      Parameters:
      input - The input text.
      Returns:
      The converted text, or the input when no conversion applies.
    • anyReplacement

      boolean anyReplacement(String input, Predicate<String> accepted)
      Tests individual replacements without combining separate corrections.
      Parameters:
      input - The candidate compound.
      accepted - Tests whether a replacement is a recognized non-compound word.
      Returns:
      Whether a replacement satisfies the test.