Class EmojiSentimentContextGenerator

java.lang.Object
opennlp.tools.sentiment.SentimentContextGenerator
opennlp.tools.sentiment.EmojiSentimentContextGenerator
All Implemented Interfaces:
opennlp.tools.util.BeamSearchContextGenerator<String>

public class EmojiSentimentContextGenerator extends SentimentContextGenerator
A SentimentContextGenerator that adds emoji annotation features to the default token context: for every annotated token the project-authored coarse sentiment score (emojiSentiment=2), the entity type (emojiType=HEART), the category (emojiCategory=SMILEYS_AND_EMOTION), and for flags the region (emojiRegion=DE). A crying-face or heart pictograph thereby becomes direct evidence for the sentiment model instead of an opaque token.

Strictly opt-in through the SentimentFactory seam: train with EmojiSentimentFactory (or any factory whose SentimentFactory.createContextGenerator() returns this class) and the same context is regenerated at prediction time; the default factory and existing models are unchanged.

See Also:
  • Constructor Details

    • EmojiSentimentContextGenerator

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

      public EmojiSentimentContextGenerator(EmojiAnnotator annotator)
      Instantiates a context 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

    • getContext

      public String[] getContext(String[] text)
      Returns the context

      Appends the emoji annotation features of every annotated token to the default token context.

      Overrides:
      getContext in class SentimentContextGenerator
      Parameters:
      text - the given text to be returned as context
      Returns:
      the text (the context)
      Throws:
      IllegalArgumentException - if text is null.