Package opennlp.tools.util.normalizer
Record Class EmojiAnnotation
java.lang.Object
java.lang.Record
opennlp.tools.util.normalizer.EmojiAnnotation
- Record Components:
symbol- The annotated code point sequence, without the U+FE0F presentation selector.attributes- The attribute values keyed by attribute name (NAME,SENTIMENT,ENTITY_TYPE,CATEGORY).
public record EmojiAnnotation(String symbol, Map<String,EmojiAnnotation.Value> attributes)
extends Record
The annotation record of one emoji: an extensible per-symbol store of attribute values, each
carrying its own provenance. A record is assembled from up to three strictly separated layers:
bundled facts from
emoji-annotations.txt (see EmojiAnnotations), derived facts
computed from the code point sequence itself, and joined facts resolved at run time against
user-installed data. The typed accessors (name(), sentiment(),
entityType(), category()) are projections of the attributes() map,
so an attribute added later is new rows plus an accessor, not a shape change.
Every attribute is optional: a consumer that only wants one dimension pays nothing for the rest, and a record never fabricates a value it has no source for. Instances are immutable and thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne attribute value with its provenance, mirroring one row of the bundled data file. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe attribute key of thedocument-category hint.static final StringThe attribute key of the coarseentity type.static final StringThe attribute key of the ISO 3166 region code of a flag emoji.static final StringThe attribute key of the human-readable name (the CLDR short name).static final StringThe attribute key of the project-authored coarse sentiment score, an integer in -2..2. -
Constructor Summary
ConstructorsConstructorDescriptionEmojiAnnotation(String symbol, Map<String, EmojiAnnotation.Value> attributes) Creates a record; normally records come fromEmojiAnnotations.lookup(CharSequence). -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of one attribute with its provenance.Returns the value of theattributesrecord component.category()Returns the document-category hint, or empty when not annotated.Returns the coarse entity type, or empty when not annotated.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the ISO 3166 code of a flag emoji (DE,GB-ENG), or empty when this record is not a flag.name()Returns the human-readable name (the CLDR short name), or empty when not annotated.Returns the project-authored coarse sentiment score in -2..2, or empty when not annotated.symbol()Returns the value of thesymbolrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
NAME
The attribute key of the human-readable name (the CLDR short name).- See Also:
-
SENTIMENT
The attribute key of the project-authored coarse sentiment score, an integer in -2..2.- See Also:
-
ENTITY_TYPE
The attribute key of the coarseentity type.- See Also:
-
CATEGORY
The attribute key of thedocument-category hint.- See Also:
-
ISO_REGION
The attribute key of the ISO 3166 region code of a flag emoji. Never a bundled row: the value is decoded from the code point sequence by the derived layer (seeEmojiFlags).- See Also:
-
-
Constructor Details
-
EmojiAnnotation
Creates a record; normally records come fromEmojiAnnotations.lookup(CharSequence).- Parameters:
symbol- The annotated code point sequence. Must not benullor empty.attributes- The attribute values keyed by attribute name. Must not benullor containnullkeys or values; it is defensively copied.- Throws:
IllegalArgumentException- ifsymbolisnullor empty, or ifattributesisnullor contains anullkey or value.
-
-
Method Details
-
attribute
Returns the value of one attribute with its provenance.- Parameters:
name- The attribute name, for exampleNAME. Must not benull.- Returns:
- The value, or empty when this record does not carry the attribute.
- Throws:
IllegalArgumentException- ifnameisnull.
-
name
Returns the human-readable name (the CLDR short name), or empty when not annotated.- Returns:
- the human-readable name (the CLDR short name), or empty when not annotated
-
isoRegion
Returns the ISO 3166 code of a flag emoji (DE,GB-ENG), or empty when this record is not a flag. Populated by the derived layer throughEmojiAnnotator.- Returns:
- the ISO 3166 code of a flag emoji (
DE,GB-ENG), or empty when this record is not a flag
-
sentiment
Returns the project-authored coarse sentiment score in -2..2, or empty when not annotated.- Returns:
- the project-authored coarse sentiment score in -2..2, or empty when not annotated
- Throws:
IllegalStateException- if the stored value is not an integer, which cannot happen for records loaded from the bundled data (the loader validates it).
-
entityType
Returns the coarse entity type, or empty when not annotated.- Returns:
- the coarse entity type, or empty when not annotated
- Throws:
IllegalStateException- if the stored value is not anEmojiEntityTypeconstant, which cannot happen for records loaded from the bundled data (the loader validates it).
-
category
Returns the document-category hint, or empty when not annotated.- Returns:
- the document-category hint, or empty when not annotated
- Throws:
IllegalStateException- if the stored value is not anEmojiCategoryconstant, which cannot happen for records loaded from the bundled data (the loader validates it).
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
symbol
Returns the value of thesymbolrecord component.- Returns:
- the value of the
symbolrecord component
-
attributes
Returns the value of theattributesrecord component.- Returns:
- the value of the
attributesrecord component
-