Package opennlp.tools.tokenize.uax29
Class ExtendedPictographic
java.lang.Object
opennlp.tools.tokenize.uax29.ExtendedPictographic
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
FieldsModifier and TypeFieldDescriptionprivate static final BundledUnicodeData.Lazy<BitSet> private static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanis(int codePoint) Returns whether a code point has theExtended_Pictographicproperty.(package private) static booleanLikeis(int)but against an already-resolved set, so a caller that checks many code points in one pass (WordSegmenter,WordType) pays the volatile read behindmembers()once for the whole pass rather than once per code point.private static BitSetload()Returns the member set parsed from the bundledExtendedPictographic.txtresource.(package private) static BitSetmembers()Returns the resolved member bit set.(package private) static voidparse(InputStream in, BitSet set) ParsesExtended_Pictographicdefinition lines intoset.
-
Field Details
-
RESOURCE
- See Also:
-
MEMBERS
-
-
Constructor Details
-
ExtendedPictographic
private ExtendedPictographic()
-
-
Method Details
-
members
Returns the resolved member bit set. Package-visible so a per-pass caller can resolve the set once (seeis(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
Returns the member set parsed from the bundledExtendedPictographic.txtresource.- Returns:
- the member set parsed from the bundled
ExtendedPictographic.txtresource - Throws:
IllegalStateException- Thrown if the resource is missing.UncheckedIOException- Thrown if the resource cannot be read.IllegalArgumentException- Thrown if the data is malformed.
-
parse
ParsesExtended_Pictographicdefinition lines intoset. 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 readinginfails.IllegalArgumentException- Thrown if a definition line is malformed.
-
is
public static boolean is(int codePoint) Returns whether a code point has theExtended_Pictographicproperty.- Parameters:
codePoint- The code point. Values outside[0, U+10FFFF]returnfalse.- Returns:
- whether a code point has the
Extended_Pictographicproperty
-
is
Likeis(int)but against an already-resolved set, so a caller that checks many code points in one pass (WordSegmenter,WordType) pays the volatile read behindmembers()once for the whole pass rather than once per code point.- Parameters:
resolved- The resolved member set frommembers().codePoint- The code point. Values outside[0, U+10FFFF]returnfalse.- Returns:
- Whether the code point has the
Extended_Pictographicproperty.
-