Class BasicContextGenerator
java.lang.Object
opennlp.tools.ml.maxent.BasicContextGenerator
- All Implemented Interfaces:
ContextGenerator<String>
A
ContextGenerator implementation for maxent decisions, assuming that the input
given to the getContext(String) method is a String containing contextual
predicates separated by whitespace, for instance:
cp_1 cp_2 ... cp_n
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes aBasicContextGeneratorthat splits on runs of whitespace under the UnicodeWhite_Spaceproperty, seeStringUtil.isUnicodeWhitespace(int).Initializes aBasicContextGeneratorthat splits onseponly. -
Method Summary
Modifier and TypeMethodDescriptionString[]getContext(String o) Builds up the list of contextual predicates given anobject.
-
Constructor Details
-
BasicContextGenerator
public BasicContextGenerator()Initializes aBasicContextGeneratorthat splits on runs of whitespace under the UnicodeWhite_Spaceproperty, seeStringUtil.isUnicodeWhitespace(int). That definition is fixed and does not depend on theopennlp.whitespace.modesystem property, seeWhitespaceMode. -
BasicContextGenerator
Initializes aBasicContextGeneratorthat splits onseponly. Other whitespace is part of the predicates.- Parameters:
sep- The separator, taken as written and not as a regular expression. Must not benullor empty, and must not contain a backslash or an unpaired surrogate. A backslash is rejected to catch regular expression separators written for 2.x, such as\s+.- Throws:
IllegalArgumentException- Thrown ifsepisnull, empty, contains a backslash, or contains an unpaired surrogate.
-
-
Method Details
-
getContext
Builds up the list of contextual predicates given anobject. Splitsoat each occurrence of the separator, or on runs of Unicode whitespace if none was given, and leaves out empty parts.- Specified by:
getContextin interfaceContextGenerator<String>- Parameters:
o- Theobjectused as input.- Returns:
- The contextual predicates of
o, in order.
-