Package opennlp.tools.namefind
Class DefaultNameContextGenerator
java.lang.Object
opennlp.tools.namefind.DefaultNameContextGenerator
- All Implemented Interfaces:
NameContextGenerator
,BeamSearchContextGenerator<String>
A
NameContextGenerator
implementation for determining contextual features
for a tag-chunk
style named-entity recognizer.-
Constructor Summary
ConstructorDescriptionDefaultNameContextGenerator
(AdaptiveFeatureGenerator... featureGenerators) Creates a name context generator with the specifiedfeature generators
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFeatureGenerator
(AdaptiveFeatureGenerator generator) Adds a feature generator.void
Informs all the feature generators that the context of the adaptive data (typically a document) is no longer valid and should be cleared.String[]
getContext
(int index, String[] tokens, String[] preds, Object[] additionalContext) Finds the context for finding names at the specified index.void
updateAdaptiveData
(String[] tokens, String[] outcomes) Informs all the feature generators that the specifiedtokens
have been classified with the corresponds set of specifiedoutcomes
.
-
Constructor Details
-
DefaultNameContextGenerator
Creates a name context generator with the specifiedfeature generators
.- Parameters:
featureGenerators
- One or morefeature generators
.
-
-
Method Details
-
addFeatureGenerator
Description copied from interface:NameContextGenerator
Adds a feature generator.- Specified by:
addFeatureGenerator
in interfaceNameContextGenerator
- Parameters:
generator
- Thefeature generator
to add.
-
updateAdaptiveData
Description copied from interface:NameContextGenerator
Informs all the feature generators that the specifiedtokens
have been classified with the corresponds set of specifiedoutcomes
.- Specified by:
updateAdaptiveData
in interfaceNameContextGenerator
- Parameters:
tokens
- The tokens of a sentence or another text unit which has been processed.outcomes
- The outcomes associated with the specifiedtokens
.
-
clearAdaptiveData
public void clearAdaptiveData()Description copied from interface:NameContextGenerator
Informs all the feature generators that the context of the adaptive data (typically a document) is no longer valid and should be cleared.- Specified by:
clearAdaptiveData
in interfaceNameContextGenerator
-
getContext
Finds the context for finding names at the specified index.- Specified by:
getContext
in interfaceBeamSearchContextGenerator<String>
- Parameters:
index
- The index of the token in the specifiedtokens
for which the context should be constructed.tokens
- The tokens of the sentence. ThetoString()
methods of these objects should return the token text.preds
- The previous decisions made in the tagging of this sequence. Only indices less thanindex
will be examined.additionalContext
- Addition features which may be based on a context outside the sentence.- Returns:
- The context for finding names at the specified
index
.
-