Package opennlp.tools.util.featuregen
Class EmojiAnnotationFeatureGenerator
java.lang.Object
opennlp.tools.util.featuregen.EmojiAnnotationFeatureGenerator
- All Implemented Interfaces:
opennlp.tools.util.featuregen.AdaptiveFeatureGenerator
public class EmojiAnnotationFeatureGenerator
extends Object
implements opennlp.tools.util.featuregen.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.
- See Also:
-
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) 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
-
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- ifannotatorisnull.
-
-
Method Details
-
createFeatures
public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes) Adds one feature per present annotation attribute of the token at
index.- Specified by:
createFeaturesin interfaceopennlp.tools.util.featuregen.AdaptiveFeatureGenerator- Throws:
IllegalArgumentException- iffeaturesortokensisnull.
-