Class EmojiAnnotationFeatureGenerator

java.lang.Object
opennlp.tools.util.featuregen.EmojiAnnotationFeatureGenerator
All Implemented Interfaces:
AdaptiveFeatureGenerator

public class EmojiAnnotationFeatureGenerator extends Object implements 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 Details

  • 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 - Thrown if annotator is null.
  • Method Details

    • createFeatures

      public void createFeatures(List<String> features, String[] tokens, int index, String[] previousOutcomes)
      Adds the appropriate features for the token at the specified index with the specified array of previousOutcomes to the specified list of features.

      Adds one feature per present annotation attribute of the token at index.

      Specified by:
      createFeatures in interface AdaptiveFeatureGenerator
      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 if features or tokens is null.