Package opennlp.tools.util
Enum Class WhitespaceMode
- All Implemented Interfaces:
Serializable,Comparable<WhitespaceMode>,Constable
Selects the whitespace definition used by
StringUtil.isWhitespace(char) and
StringUtil.isWhitespace(int): the Unicode White_Space property, or
OpenNLP's legacy definition from 1.x/2.x.
Resolved from the "opennlp.whitespace.mode" system property when this class is initialized
and shared process-wide, so a model is trained and decoded under one definition. Tests and
embedders may override the mode via setActive(WhitespaceMode) and reset().
- Since:
- 3.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionOpenNLP 1.x/2.x whitespace: the union ofCharacter.isWhitespace(int)and the UnicodeZscategory.The UnicodeWhite_Spaceproperty. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property that selects the activeWhitespaceModeat startup. -
Method Summary
Modifier and TypeMethodDescriptionstatic WhitespaceModecurrent()Returns the activeWhitespaceMode: the value resolved from the "opennlp.whitespace.mode" system property when this class was initialized, or the value most recently passed tosetActive(WhitespaceMode).static voidreset()Discards any override set viasetActive(WhitespaceMode)and re-resolves the active mode from the "opennlp.whitespace.mode" system property.static voidsetActive(WhitespaceMode mode) Overrides the activeWhitespaceModefor the whole process, taking precedence over the "opennlp.whitespace.mode" system property.static WhitespaceModeReturns the enum constant of this class with the specified name.static WhitespaceMode[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
LEGACY
OpenNLP 1.x/2.x whitespace: the union ofCharacter.isWhitespace(int)and the UnicodeZscategory. Restores byte-identical tokenization, corpus parsing, and feature generation for models trained under this definition. -
UNICODE
The UnicodeWhite_Spaceproperty. The default from 3.0 onward.
-
-
Field Details
-
MODE_PROPERTY
System property that selects the activeWhitespaceModeat startup. AcceptsLEGACYorUNICODE, case-insensitive; unset or blank resolves toUNICODE, any other value raises anIllegalArgumentExceptionwhen the mode is resolved.- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
current
Returns the activeWhitespaceMode: the value resolved from the "opennlp.whitespace.mode" system property when this class was initialized, or the value most recently passed tosetActive(WhitespaceMode).- Returns:
- The active
WhitespaceMode.
-
setActive
Overrides the activeWhitespaceModefor the whole process, taking precedence over the "opennlp.whitespace.mode" system property. Intended for tests and embedders; callers pinning a mode temporarily should callreset()afterward.- Parameters:
mode- TheWhitespaceModeto activate. Must not benull.- Throws:
IllegalArgumentException- Ifmodeisnull.
-
reset
public static void reset()Discards any override set viasetActive(WhitespaceMode)and re-resolves the active mode from the "opennlp.whitespace.mode" system property.- Throws:
IllegalArgumentException- If the property holds a value other thanLEGACYorUNICODE(case-insensitive); the previous mode is retained.
-