Package opennlp.tools.sentiment
Class EmojiSentimentContextGenerator
java.lang.Object
opennlp.tools.sentiment.SentimentContextGenerator
opennlp.tools.sentiment.EmojiSentimentContextGenerator
- All Implemented Interfaces:
opennlp.tools.util.BeamSearchContextGenerator<String>
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 Summary
ConstructorsConstructorDescriptionInstantiates a context generator over the bundled and derived annotation layers.EmojiSentimentContextGenerator(EmojiAnnotator annotator) Instantiates a context generator over a configured annotator, for example one with a gazetteer join. -
Method Summary
Methods inherited from class opennlp.tools.sentiment.SentimentContextGenerator
getContext, updateAdaptiveData
-
Constructor Details
-
EmojiSentimentContextGenerator
public EmojiSentimentContextGenerator()Instantiates a context generator over the bundled and derived annotation layers. -
EmojiSentimentContextGenerator
Instantiates a context 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
-
getContext
Returns the contextAppends the emoji annotation features of every annotated token to the default token context.
- Overrides:
getContextin classSentimentContextGenerator- Parameters:
text- the given text to be returned as context- Returns:
- the text (the context)
- Throws:
IllegalArgumentException- iftextisnull.
-