Package opennlp.tools.util.normalizer
Class EmojiAnnotator
java.lang.Object
opennlp.tools.util.normalizer.EmojiAnnotator
Assembles one
EmojiAnnotation per symbol from bundled facts
(EmojiAnnotations), derived facts (EmojiFlags), and optional joined facts
(EmojiAnnotationJoin). annotate(Term) keys on Term.original();
non-emoji tokens and degenerate flag-shaped text return empty. Instances are immutable and
thread-safe when the join is.
Annotations are per-symbol metadata, not text transforms; a parallel surface beside
Term rather than Dimension constants. See OPENNLP-1870.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an annotator over the bundled and derived layers only.Creates an annotator that also resolves joined facts throughjoin. -
Method Summary
Modifier and TypeMethodDescriptionannotate(CharSequence symbol) Annotates one symbol.Annotates one term, keyed on itsoriginaltext (see the class note on why the original layer is the one annotations describe).voidcollectFeatures(CharSequence token, Collection<String> features) Appends this annotator's features fortokentofeatures: one entry per present annotation attribute (sentiment, entity type, category, region), each already name-prefixed.
-
Constructor Details
-
EmojiAnnotator
public EmojiAnnotator()Creates an annotator over the bundled and derived layers only. -
EmojiAnnotator
Creates an annotator that also resolves joined facts throughjoin.- Parameters:
join- The joined-facts hook, called while a record is assembled. Must not benull.- Throws:
IllegalArgumentException- ifjoinisnull.
-
-
Method Details
-
annotate
Annotates one term, keyed on itsoriginaltext (see the class note on why the original layer is the one annotations describe).- Parameters:
term- The term to annotate. Must not benull.- Returns:
- The assembled record, or empty when the term is not an annotated symbol.
- Throws:
IllegalArgumentException- iftermisnull.IllegalStateException- if the configured join violates its contract (returnsnullor a key colliding with an existing attribute).
-
annotate
Annotates one symbol.- Parameters:
symbol- The code point sequence of one symbol (one token). U+FE0F presentation selectors are ignored. Must not benull.- Returns:
- The assembled record, or empty when
symbolis not an annotated symbol. - Throws:
IllegalArgumentException- ifsymbolisnull.IllegalStateException- if the configured join violates its contract (returnsnullor a key colliding with an existing attribute).
-
collectFeatures
Appends this annotator's features fortokentofeatures: one entry per present annotation attribute (sentiment, entity type, category, region), each already name-prefixed. A token that carries no emoji annotation contributes nothing, so callers may pass every token.- Parameters:
token- The token to describe. Must not benull.features- The collection to append feature strings to. Must not benull.- Throws:
IllegalArgumentException- iftokenorfeaturesisnull.IllegalStateException- if the configured join violates its contract (seeannotate(CharSequence)).
-