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 Classes
  Modifier and Type
  Class
  Description
  `static final record`
  `EmojiAnnotation.Value`
  One attribute value with its provenance, mirroring one row of the bundled data file.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `CATEGORY`
  The attribute key of the `document-category hint`.
  `static final String`
  `ENTITY_TYPE`
  The attribute key of the coarse `entity type`.
  `static final String`
  `ISO_REGION`
  The attribute key of the ISO 3166 region code of a flag emoji.
  `static final String`
  `NAME`
  The attribute key of the human-readable name (the CLDR short name).
  `static final String`
  `SENTIMENT`
  The attribute key of the project-authored coarse sentiment score, an integer in -2..2.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `EmojiAnnotation(String symbol, Map<String,EmojiAnnotation.Value> attributes)`
  Creates a record; normally records come from `EmojiAnnotations.lookup(CharSequence)`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Optional<EmojiAnnotation.Value>`
  `attribute(String name)`
  Returns the value of one attribute with its provenance.
  `Map<String,EmojiAnnotation.Value>`
  `attributes()`
  Returns the value of the `attributes` record component.
  `Optional<EmojiCategory>`
  `category()`
  Returns the document-category hint, or empty when not annotated.
  `Optional<EmojiEntityType>`
  `entityType()`
  Returns the coarse entity type, or empty when not annotated.
  `final boolean`
  `equals(Object o)`
  Indicates whether some other object is "equal to" this one.
  `final int`
  `hashCode()`
  Returns a hash code value for this object.
  `Optional<String>`
  `isoRegion()`
  Returns the ISO 3166 code of a flag emoji (`DE`, `GB-ENG`), or empty when this record is not a flag.
  `Optional<String>`
  `name()`
  Returns the human-readable name (the CLDR short name), or empty when not annotated.
  `OptionalInt`
  `sentiment()`
  Returns the project-authored coarse sentiment score in -2..2, or empty when not annotated.
  `String`
  `symbol()`
  Returns the value of the `symbol` record component.
  `final String`
  `toString()`
  Returns a string representation of this record class.

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### NAME

    public static final String NAME
    The attribute key of the human-readable name (the CLDR short name).
    See Also:
      - Constant Field Values

  - ### SENTIMENT

    public static final String SENTIMENT
    The attribute key of the project-authored coarse sentiment score, an integer in -2..2.
    See Also:
      - Constant Field Values

  - ### ENTITY_TYPE

    public static final String ENTITY_TYPE
    The attribute key of the coarse `entity type`.
    See Also:
      - Constant Field Values

  - ### CATEGORY

    public static final String CATEGORY
    The attribute key of the `document-category hint`.
    See Also:
      - Constant Field Values

  - ### ISO_REGION

    public static final String 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 (see `EmojiFlags`).
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### EmojiAnnotation

    public EmojiAnnotation(String symbol, Map<String,EmojiAnnotation.Value> attributes)
    Creates a record; normally records come from `EmojiAnnotations.lookup(CharSequence)`.
    Parameters:
      `symbol` - The annotated code point sequence. Must not be `null` or empty.
      `attributes` - The attribute values keyed by attribute name. Must not be `null` or contain `null` keys or values; it is defensively copied.
    Throws:
      `IllegalArgumentException` - if `symbol` is `null` or empty, or if `attributes` is `null` or contains a `null` key or value.

- ## Method Details

  - ### attribute

    public Optional<EmojiAnnotation.Value> attribute(String name)
    Returns the value of one attribute with its provenance.
    Parameters:
      `name` - The attribute name, for example `NAME`. Must not be `null`.
    Returns:
      The value, or empty when this record does not carry the attribute.
    Throws:
      `IllegalArgumentException` - if `name` is `null`.

  - ### name

    public Optional<String> 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

    public Optional<String> 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 through `EmojiAnnotator`.
    Returns:
      the ISO 3166 code of a flag emoji (`DE`, `GB-ENG`), or empty when this record is not a flag

  - ### sentiment

    public OptionalInt 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

    public Optional<EmojiEntityType> 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 an `EmojiEntityType` constant, which cannot happen for records loaded from the bundled data (the loader validates it).

  - ### category

    public Optional<EmojiCategory> 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 an `EmojiCategory` constant, which cannot happen for records loaded from the bundled data (the loader validates it).

  - ### toString

    public final String 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.
    Specified by:
      `toString` in class `Record`
    Returns:
      a string representation of this object

  - ### 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.
    Specified by:
      `hashCode` in class `Record`
    Returns:
      a hash code value for this object

  - ### equals

    public final boolean equals(Object o)
    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 with `Objects::equals(Object,Object)`.
    Specified by:
      `equals` in class `Record`
    Parameters:
      `o` - the object with which to compare
    Returns:
      `true` if this object is the same as the `o` argument; `false` otherwise.

  - ### symbol

    public String symbol()
    Returns the value of the `symbol` record component.
    Returns:
      the value of the `symbol` record component

  - ### attributes

    public Map<String,EmojiAnnotation.Value> attributes()
    Returns the value of the `attributes` record component.
    Returns:
      the value of the `attributes` record component