Class DictionaryFeatureGenerator
- All Implemented Interfaces:
opennlp.tools.util.featuregen.AdaptiveFeatureGenerator
DictionaryFeatureGenerator uses a DictionaryNameFinder
to generate features for detected names based on the InSpanGenerator.
Thread safety: in normal use the underlying InSpanGenerator is configured once at
construction time and never replaced, after which createFeatures(java.util.List<java.lang.String>, java.lang.String[], int, java.lang.String[]) is safe to call from
many threads concurrently (it delegates to a thread-safe InSpanGenerator). The isg
field is volatile to give safe publication for both that one-shot constructor write and
any later setDictionary call.
setDictionary replaces the in-flight dictionary; it is intended
for setup time and is not for hot-path use while createFeatures(java.util.List<java.lang.String>, java.lang.String[], int, java.lang.String[]) is running on
other threads — it does not coordinate with in-flight reads beyond the volatile publish, so a
caller racing dictionary replacement against feature generation may observe either the old or the
new dictionary's features for any given call.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDictionaryFeatureGenerator(String prefix, Dictionary dict) Initializes aDictionaryFeatureGeneratorwith the specified parameters.Initializes aDictionaryFeatureGeneratorwith the specifiedDictionary. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) voidsetDictionary(String name, Dictionary dict) voidsetDictionary(Dictionary dict) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface opennlp.tools.util.featuregen.AdaptiveFeatureGenerator
clearAdaptiveData, updateAdaptiveData
-
Constructor Details
-
DictionaryFeatureGenerator
Initializes aDictionaryFeatureGeneratorwith the specifiedDictionary.- Parameters:
dict- TheDictionaryto use. Must not benull.
-
DictionaryFeatureGenerator
Initializes aDictionaryFeatureGeneratorwith the specified parameters.- Parameters:
prefix- The prefix to set. Must not benullbut may be empty.dict- TheDictionaryto use. Must not benull.
-
-
Method Details