Package opennlp.tools.util.normalizer
Class DigitCharSequenceNormalizer
java.lang.Object
opennlp.tools.util.normalizer.DigitCharSequenceNormalizer
- All Implemented Interfaces:
Serializable,CharSequenceNormalizer,OffsetAwareNormalizer
A
CharSequenceNormalizer that maps Unicode decimal digits to their ASCII equivalents,
so for example Arabic-Indic, Devanagari, or fullwidth digits all become 0-9.
It maps a code point when Character.digit(int, int) reports a value of 0-
9 in radix ten, that is, when the code point is a Unicode decimal digit. Other numeric
forms (Roman numerals, superscripts, circled numbers, fractions) are not decimal digits and are
left unchanged.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final DigitCharSequenceNormalizerprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DigitCharSequenceNormalizerReturns 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.private static StringtoAscii(int codePoint) Maps a code point to its ASCII digit fold.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
INSTANCE
-
-
Constructor Details
-
DigitCharSequenceNormalizer
public DigitCharSequenceNormalizer()
-
-
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.
-
toAscii
Maps a code point to its ASCII digit fold.- Parameters:
codePoint- The code point to fold.- Returns:
- The ASCII digit string for a non-ASCII Unicode decimal digit, or
nullto copy the code point through (ASCII digits are already their own fold).
-
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
-