Package opennlp.tools.util.normalizer
Class DashCharSequenceNormalizer
java.lang.Object
opennlp.tools.util.normalizer.DashCharSequenceNormalizer
- All Implemented Interfaces:
Serializable,CharSequenceNormalizer,OffsetAwareNormalizer
A
CharSequenceNormalizer that maps every Unicode dash to an ASCII hyphen-minus
(U+002D), reusing the cursor based CharClass.dashes() engine.
This folds the many dash code points (en dash, em dash, figure dash, non-breaking hyphen,
fullwidth hyphen, and so on) to a single form so that "state-of-the-art" matches
regardless of which dash the source used. The mathematical minus signs are left untouched by
default, and U+00AD SOFT HYPHEN (a format character) is not treated as a dash.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final CharClassprivate static final DashCharSequenceNormalizerprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DashCharSequenceNormalizerReturns 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:
-
DASHES
-
INSTANCE
-
-
Constructor Details
-
DashCharSequenceNormalizer
public DashCharSequenceNormalizer()
-
-
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
-