Package opennlp.tools.util.normalizer
Class LineBreakPreservingWhitespaceCharSequenceNormalizer
java.lang.Object
opennlp.tools.util.normalizer.LineBreakPreservingWhitespaceCharSequenceNormalizer
- All Implemented Interfaces:
Serializable,opennlp.tools.util.normalizer.CharSequenceNormalizer,opennlp.tools.util.normalizer.OffsetAwareNormalizer
public class LineBreakPreservingWhitespaceCharSequenceNormalizer
extends Object
implements opennlp.tools.util.normalizer.OffsetAwareNormalizer
An
OffsetAwareNormalizer that collapses runs of Unicode whitespace like
WhitespaceCharSequenceNormalizer, but keeps line and paragraph structure: any whitespace
run that contains a line break collapses to a single newline (U+000A) instead of a space,
and leading and trailing whitespace is trimmed.
This is the form wanted for readable snippets and display: horizontal runs of spaces and tabs
become a single space, yet a blank line between paragraphs survives as one newline rather than
being flattened into the surrounding text. It reuses the cursor based
CharClass.collapsePreserving(CharSequence, CodePointSet, int) engine, so it recognizes the
full Unicode White_Space set with no regular expression.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the shared, stateless instance.normalize(CharSequence text) opennlp.tools.util.normalizer.AlignedTextnormalizeAligned(CharSequence text)
-
Constructor Details
-
LineBreakPreservingWhitespaceCharSequenceNormalizer
public LineBreakPreservingWhitespaceCharSequenceNormalizer()
-
-
Method Details
-
getInstance
Returns the shared, stateless instance.- Returns:
- the shared, stateless instance
-
normalize
- Specified by:
normalizein interfaceopennlp.tools.util.normalizer.CharSequenceNormalizer
-
normalizeAligned
- Specified by:
normalizeAlignedin interfaceopennlp.tools.util.normalizer.OffsetAwareNormalizer
-