Class EmojiAnnotations

java.lang.Object
opennlp.tools.util.normalizer.EmojiAnnotations

public final class EmojiAnnotations extends Object
The bundled-facts layer of the emoji annotation record store: license-clean, provenance-tagged attributes intrinsic to a pictograph (name, coarse sentiment, entity type, document category), loaded on first use from the project-authored emoji-annotations.txt resource. Each row of that file is one attribute of one symbol (codepoints ; attribute ; value ; source ; notes), so every value carries its own provenance and adding an attribute later is new rows plus loader support instead of a file-format break. The loader fails loud on an unknown attribute or a malformed row: the data and the code move together, so an unrecognized attribute is corruption, not extensibility.

Data licensing: the name values are the CLDR short names and the entity-type/category values are derived from the group and subgroup headers of the upstream emoji-test.txt (UTS #51, Unicode License V3, see the NOTICE file); the sentiment scores are original project judgments tagged UNSPECIFIED. No third-party sentiment data set is copied; in particular the Emoji Sentiment Ranking (CC BY-SA) is not used in any form.

EmojiAnnotator is the accessor. Lookups strip U+FE0F (emoji presentation selector) because it does not change identity; bundled rows are keyed without it. Flag emoji have no bundled rows: region is derived, and gazetteer ids are never baked in.

  • Method Details

    • lookup

      public static Optional<EmojiAnnotation> lookup(CharSequence symbol)
      Returns the bundled annotation record of one emoji. The bundled data is loaded on the first call; a failed load is not cached, so the next call loads again.
      Parameters:
      symbol - The code point sequence of one symbol, for example one Term.original() token. U+FE0F presentation selectors are ignored. Must not be null.
      Returns:
      The record, or empty when the bundled data does not annotate the symbol.
      Throws:
      IllegalArgumentException - Thrown if symbol is null, or if the bundled data is malformed.
      IllegalStateException - Thrown if the bundled data resource is missing.
      UncheckedIOException - Thrown if the bundled data resource cannot be read.