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 Details

    • EmojiAnnotationFeatureGenerator

      public EmojiAnnotationFeatureGenerator()
      Instantiates a generator over the bundled and derived annotation layers.
    • EmojiAnnotationFeatureGenerator

      public EmojiAnnotationFeatureGenerator(EmojiAnnotator annotator)
      Instantiates a generator over a configured annotator, for example one with a gazetteer join.
      Parameters:
      annotator - The annotator to use. Must not be null.
      Throws:
      IllegalArgumentException - if annotator is null.
  • 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:
      createFeatures in interface opennlp.tools.util.featuregen.AdaptiveFeatureGenerator
      Throws:
      IllegalArgumentException - if features or tokens is null.