Package opennlp.tools.namefind
Class DefaultNameContextGenerator
- java.lang.Object
-
- opennlp.tools.namefind.DefaultNameContextGenerator
-
- All Implemented Interfaces:
NameContextGenerator,BeamSearchContextGenerator<String>
public class DefaultNameContextGenerator extends Object implements NameContextGenerator
ANameContextGeneratorimplementation for determining contextual features for atag-chunkstyle named-entity recognizer.
-
-
Constructor Summary
Constructors Constructor Description DefaultNameContextGenerator()Deprecated.useDefaultNameContextGenerator(AdaptiveFeatureGenerator...)and always provide one or morefeature generators.DefaultNameContextGenerator(AdaptiveFeatureGenerator... featureGenerators)Creates a name context generator with the specifiedfeature generators.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFeatureGenerator(AdaptiveFeatureGenerator generator)Adds a feature generator.voidclearAdaptiveData()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.voidupdateAdaptiveData(String[] tokens, String[] outcomes)Informs all the feature generators that the specifiedtokenshave been classified with the corresponds set of specifiedoutcomes.
-
-
-
Constructor Detail
-
DefaultNameContextGenerator
@Deprecated public DefaultNameContextGenerator()
Deprecated.useDefaultNameContextGenerator(AdaptiveFeatureGenerator...)and always provide one or morefeature generators.Creates a name context generator.
-
DefaultNameContextGenerator
public DefaultNameContextGenerator(AdaptiveFeatureGenerator... featureGenerators)
Creates a name context generator with the specifiedfeature generators.- Parameters:
featureGenerators- One or morefeature generators. If none are provided, a default config (WINDOW_FEATURES) will be used.
-
-
Method Detail
-
addFeatureGenerator
public void addFeatureGenerator(AdaptiveFeatureGenerator generator)
Description copied from interface:NameContextGeneratorAdds a feature generator.- Specified by:
addFeatureGeneratorin interfaceNameContextGenerator- Parameters:
generator- Thefeature generatorto add.
-
updateAdaptiveData
public void updateAdaptiveData(String[] tokens, String[] outcomes)
Description copied from interface:NameContextGeneratorInforms all the feature generators that the specifiedtokenshave been classified with the corresponds set of specifiedoutcomes.- Specified by:
updateAdaptiveDatain 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:NameContextGeneratorInforms all the feature generators that the context of the adaptive data (typically a document) is no longer valid and should be cleared.- Specified by:
clearAdaptiveDatain interfaceNameContextGenerator
-
getContext
public String[] getContext(int index, String[] tokens, String[] preds, Object[] additionalContext)
Finds the context for finding names at the specified index.- Specified by:
getContextin interfaceBeamSearchContextGenerator<String>- Parameters:
index- The index of the token in the specifiedtokensfor 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 thanindexwill 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.
-
-