Package opennlp.tools.stemmer.hunspell
Class AffixCondition
java.lang.Object
opennlp.tools.stemmer.hunspell.AffixCondition
One parsed affix condition: a fixed-length sequence of literal code points and
bracketed character classes, matched with a single scan and no regular expressions.
A suffix condition anchors at the end of the candidate stem, a prefix condition at
its start; the condition
. matches everything. Positions are Unicode code
points so supplementary characters agree with FLAG UTF-8 flag reading.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int[][]Per position: the accepted code points, ornullfor any code point.private static final AffixConditionThe shared instance for the condition., which accepts every stem.private final boolean[]Per position with a class: whether the class is negated;nullrows unused.private final booleanWhether the owning rule is a suffix rule, which anchors the condition at the end. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAffixCondition(int[][] accepted, boolean[] negated, boolean suffix) Initializes the condition. -
Method Summary
Modifier and TypeMethodDescription(package private) booleanTests a candidate stem against the condition at its anchored side: the last positions of the stem for a suffix condition, the first positions for a prefix condition.(package private) static AffixConditionParses a condition field.
-
Field Details
-
ANY
The shared instance for the condition., which accepts every stem. -
accepted
private final int[][] acceptedPer position: the accepted code points, ornullfor any code point. -
negated
private final boolean[] negatedPer position with a class: whether the class is negated;nullrows unused. -
suffix
private final boolean suffixWhether the owning rule is a suffix rule, which anchors the condition at the end.
-
-
Constructor Details
-
AffixCondition
private AffixCondition(int[][] accepted, boolean[] negated, boolean suffix) Initializes the condition.- Parameters:
accepted- The accepted code points per position.negated- The negation marker per position.suffix- Whether the owning rule is a suffix rule.
-
-
Method Details
-
parse
Parses a condition field. Each pattern position is a literal code point, a.matching any code point, or a bracketed class such as[sx]; a class starting with^is negated and matches any code point outside it.- Parameters:
pattern- The condition text from the affix rule.suffix- Whether the owning rule is a suffix rule.lineNumber- The affix file line, for error messages.- Returns:
- The parsed condition. Never
null. - Throws:
IOException- Thrown if a character class is unterminated.
-
matches
Tests a candidate stem against the condition at its anchored side: the last positions of the stem for a suffix condition, the first positions for a prefix condition. A stem shorter than the condition never matches. Length is in code points.- Parameters:
stem- The candidate stem after affix removal and strip restoration.- Returns:
trueif the stem satisfies the condition.
-