Package opennlp.tools.util.normalizer
Class InvisibleCharSequenceNormalizer
java.lang.Object
opennlp.tools.util.normalizer.InvisibleCharSequenceNormalizer
- All Implemented Interfaces:
Serializable,CharSequenceNormalizer,OffsetAwareNormalizer
A
CharSequenceNormalizer that removes invisible format and bidirectional control
characters that add no textual content and are a common source of noise and spoofing (the
byte-order mark, zero width space, word joiner, bidi marks/embeddings/overrides/isolates, the
invisible math operators, soft hyphen, and the Arabic letter mark).
Membership is an O(1) CharClass lookup. The zero width joiner (U+200D) and
non-joiner (U+200C) are deliberately kept, because they carry meaning in
Persian, Indic scripts, and emoji sequences; so are variation selectors. Use this only for a
matching/search form, not for display.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final InvisibleCharSequenceNormalizerprivate static final CharClassprivate 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.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
INVISIBLE
-
INSTANCE
-
-
Constructor Details
-
InvisibleCharSequenceNormalizer
public InvisibleCharSequenceNormalizer()
-
-
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.
-