Class ExtendedPictographic

java.lang.Object
opennlp.tools.tokenize.uax29.ExtendedPictographic

public final class ExtendedPictographic extends Object
Checks the Unicode Extended_Pictographic property of a code point.

This is the one extra property the word boundary algorithm needs (rule WB3c), to keep emoji zero-width-joiner sequences together. The data is loaded on first use from the bundled ExtendedPictographic.txt resource, the Extended_Pictographic lines extracted from the Unicode 18.0 emoji-data.txt, and stored in a BitSet, so membership is an O(1) bit check.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final BundledUnicodeData.Lazy<BitSet>
     
    private static final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    is(int codePoint)
    Returns whether a code point has the Extended_Pictographic property.
    (package private) static boolean
    is(BitSet resolved, int codePoint)
    Like is(int) but against an already-resolved set, so a caller that checks many code points in one pass (WordSegmenter, WordType) pays the volatile read behind members() once for the whole pass rather than once per code point.
    private static BitSet
    Returns the member set parsed from the bundled ExtendedPictographic.txt resource.
    (package private) static BitSet
    Returns the resolved member bit set.
    (package private) static void
    Parses Extended_Pictographic definition lines into set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ExtendedPictographic

      private ExtendedPictographic()
  • Method Details

    • members

      static BitSet members()
      Returns the resolved member bit set. Package-visible so a per-pass caller can resolve the set once (see is(BitSet, int)) rather than once per code point.
      Returns:
      the resolved member bit set
      Throws:
      IllegalStateException - Thrown if the bundled data resource is missing.
      UncheckedIOException - Thrown if the bundled data resource cannot be read.
      IllegalArgumentException - Thrown if the bundled data is malformed.
    • load

      private static BitSet load()
      Returns the member set parsed from the bundled ExtendedPictographic.txt resource.
      Returns:
      the member set parsed from the bundled ExtendedPictographic.txt resource
      Throws:
      IllegalStateException - Thrown if the resource is missing.
      UncheckedIOException - Thrown if the resource cannot be read.
      IllegalArgumentException - Thrown if the data is malformed.
    • parse

      static void parse(InputStream in, BitSet set) throws IOException
      Parses Extended_Pictographic definition lines into set. Package-visible so the malformed-data handling can be exercised without the bundled resource.
      Parameters:
      in - The definition lines to read.
      set - The bit set receiving the member code points.
      Throws:
      IOException - Thrown if reading in fails.
      IllegalArgumentException - Thrown if a definition line is malformed.
    • is

      public static boolean is(int codePoint)
      Returns whether a code point has the Extended_Pictographic property.
      Parameters:
      codePoint - The code point. Values outside [0, U+10FFFF] return false.
      Returns:
      whether a code point has the Extended_Pictographic property
    • is

      static boolean is(BitSet resolved, int codePoint)
      Like is(int) but against an already-resolved set, so a caller that checks many code points in one pass (WordSegmenter, WordType) pays the volatile read behind members() once for the whole pass rather than once per code point.
      Parameters:
      resolved - The resolved member set from members().
      codePoint - The code point. Values outside [0, U+10FFFF] return false.
      Returns:
      Whether the code point has the Extended_Pictographic property.