Package opennlp.tools.util.featuregen
Class EmojiAnnotationFeatureGenerator
java.lang.Object
opennlp.tools.util.featuregen.EmojiAnnotationFeatureGenerator
- All Implemented Interfaces:
AdaptiveFeatureGenerator
Generates features from the emoji annotation layer for the token at the given index: the
project-authored coarse sentiment score (
emojiSentiment=2), the entity type
(emojiType=HEART), the document category (emojiCategory=SMILEYS_AND_EMOTION),
and for flags the ISO 3166 region (emojiRegion=DE). For the name finder the entity
type behaves like gazetteer evidence: a flag token carries emojiType=FLAG and its
region without any dictionary.
Strictly opt-in: this generator only runs when a feature generation descriptor names
EmojiAnnotationFeatureGeneratorFactory, so default descriptors and existing models are
unchanged. A token that is not an annotated symbol contributes no features.
Unlike most feature generators this one is stateless and thread-safe (when its annotator's join is): it keeps no adaptive data.
- Since:
- 3.0.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a generator over the bundled and derived annotation layers.EmojiAnnotationFeatureGenerator(EmojiAnnotator annotator) Instantiates a generator over a configured annotator, for example one with a gazetteer join. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) Adds the appropriate features for the token at the specifiedindexwith the specified array ofpreviousOutcomesto the specified list of features.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface opennlp.tools.util.featuregen.AdaptiveFeatureGenerator
clearAdaptiveData, updateAdaptiveData
-
Field Details
-
annotator
-
-
Constructor Details
-
EmojiAnnotationFeatureGenerator
public EmojiAnnotationFeatureGenerator()Instantiates a generator over the bundled and derived annotation layers. -
EmojiAnnotationFeatureGenerator
Instantiates a generator over a configured annotator, for example one with a gazetteer join.- Parameters:
annotator- The annotator to use. Must not benull.- Throws:
IllegalArgumentException- Thrown ifannotatorisnull.
-
-
Method Details
-
createFeatures
public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) Adds the appropriate features for the token at the specifiedindexwith the specified array ofpreviousOutcomesto the specified list of features.Adds one feature per present annotation attribute of the token at
index.- Specified by:
createFeaturesin interfaceAdaptiveFeatureGenerator- Parameters:
features- The list of features to be added to.tokens- The tokens of the sentence or other text unit being processed.index- The index of the token which is currently being processed.previousOutcomes- The outcomes for the tokens prior to the specified index.- Throws:
IllegalArgumentException- Thrown iffeaturesortokensisnull.
-