Package opennlp.tools.stemmer.hunspell
Class HunspellConversion
java.lang.Object
opennlp.tools.stemmer.hunspell.HunspellConversion
Non-recursive longest-match input and output conversions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final recordA conversion with optional word-boundary requirements. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringMarks aREPpattern that must end the word.(package private) static final HunspellConversionAn empty conversion table.private static final StringSeparates the input and output of aph:field.private static final StringEnds aph:field whose last character is dropped from both sides.private final List<HunspellConversion.Rule> private static final StringSPACE_MARK_CHARas text, for the anchor checks.private static final charStands for a space inICONV,OCONVandREPfields.private static final StringMarks aREPpattern that must begin the word. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConstructs an immutable table. -
Method Summary
Modifier and TypeMethodDescription(package private) booleananyReplacement(String input, Predicate<String> accepted) Tests individual replacements without combining separate corrections.(package private) StringReplaces the longest matching pattern at each input position without rescanning replacement text.(package private) static HunspellConversionParses an affix conversion table and validates the entry count.(package private) HunspellConversionAdds dictionary transliterations to the replacement table.
-
Field Details
-
NONE
An empty conversion table. -
START_ANCHOR
Marks aREPpattern that must begin the word.- See Also:
-
END_ANCHOR
Marks aREPpattern that must end the word.- See Also:
-
SPACE_MARK_CHAR
private static final char SPACE_MARK_CHARStands for a space inICONV,OCONVandREPfields.- See Also:
-
SPACE_MARK
SPACE_MARK_CHARas text, for the anchor checks. -
PHONETIC_ARROW
Separates the input and output of aph:field.- See Also:
-
PHONETIC_WILDCARD
Ends aph:field whose last character is dropped from both sides.- See Also:
-
rules
-
-
Constructor Details
-
HunspellConversion
Constructs an immutable table.- Parameters:
rules- The conversion definitions.
-
-
Method Details
-
parse
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
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
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.
-