Package opennlp.tools.util.normalizer
Class EmojiToEmoticonCharSequenceNormalizer
java.lang.Object
opennlp.tools.util.normalizer.EmojiToEmoticonCharSequenceNormalizer
- All Implemented Interfaces:
Serializable,CharSequenceNormalizer,OffsetAwareNormalizer
public final class EmojiToEmoticonCharSequenceNormalizer
extends Object
implements OffsetAwareNormalizer
A
CharSequenceNormalizer that folds emoji to ASCII emoticons, using the bundled
emoji-emoticons.txt mapping (for example U+1F642 SLIGHTLY SMILING FACE to :)).
A mapped pictograph inside a larger ZWJ sequence or followed by U+FE0E VARIATION SELECTOR-15
is left untouched; a trailing U+FE0F VARIATION SELECTOR-16 after any mapped pictograph is
absorbed into the fold, so no dangling variation selector is left behind. This is an expanding,
offset-changing transform: normalizeAligned(CharSequence) reports the Alignment
from the folded text back to the input. The reverse direction is
EmoticonToEmojiCharSequenceNormalizer.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final EmojiToEmoticonCharSequenceNormalizerprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the shared, stateless instance.normalize(CharSequence text) Normalizes a sequence of characters.normalizeAligned(CharSequence text) Normalizestextand returns the result together with theAlignmentback to the input.private ObjectReturns the shared instance, so deserialization keeps the singleton.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
INSTANCE
-
-
Constructor Details
-
EmojiToEmoticonCharSequenceNormalizer
private EmojiToEmoticonCharSequenceNormalizer()Instantiated once forgetInstance().
-
-
Method Details
-
getInstance
Returns the shared, stateless instance.- Returns:
- the shared, stateless instance
-
normalize
Normalizes a sequence of characters.- Specified by:
normalizein interfaceCharSequenceNormalizer- Parameters:
text- TheCharSequenceto normalize. Must not benull.- Returns:
- The normalized
CharSequence.
-
normalizeAligned
Normalizestextand returns the result together with theAlignmentback to the input. The normalized text is identical toCharSequenceNormalizer.normalize(CharSequence): that is,normalizeAligned(text).normalized()equalsnormalize(text).toString().- Specified by:
normalizeAlignedin interfaceOffsetAwareNormalizer- Parameters:
text- TheCharSequenceto normalize.- Returns:
- The normalized text paired with its alignment to
text.
-
readResolve
Returns the shared instance, so deserialization keeps the singleton.- Returns:
- the shared instance, so deserialization keeps the singleton
-