Class HunspellCompoundRule

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

final class HunspellCompoundRule extends Object
A compound flag sequence with optional and repeated elements.
  • Field Details

    • MAX_ELEMENTS

      private static final int MAX_ELEMENTS
      Maximum elements in one compound pattern.
      See Also:
    • INVALID_PATTERN

      private static final String INVALID_PATTERN
      See Also:
    • flags

      private final int[] flags
    • repetition

      private final char[] repetition
  • Constructor Details

    • HunspellCompoundRule

      private HunspellCompoundRule(int[] flags, char[] repetition)
      Initializes a parsed compound pattern.
      Parameters:
      flags - The required flag at each position.
      repetition - The position's repetition operator or a space.
  • Method Details

    • parse

      static HunspellCompoundRule parse(String pattern, int line, HunspellCompoundRule.FlagReader reader) throws IOException
      Parses a compound rule.
      Parameters:
      pattern - The rule text.
      line - The source line.
      reader - The flag decoder.
      Returns:
      The parsed rule.
      Throws:
      IOException - Thrown if the pattern or a flag is malformed.
    • matches

      boolean matches(List<int[]> parts, boolean complete)
      Tests a sequence of selected homonyms. Each part consumes one flag position.
      Parameters:
      parts - The flags of one selected entry per compound part.
      complete - Whether the sequence must complete the rule.
      Returns:
      Whether the sequence is permitted by this rule.
    • skipOptional

      private void skipOptional(boolean[] states)
      Advances states through optional pattern elements.
      Parameters:
      states - The active pattern positions.