Class ParagraphPreservingWhitespaceCharSequenceNormalizer
java.lang.Object
opennlp.tools.util.normalizer.ParagraphPreservingWhitespaceCharSequenceNormalizer
- All Implemented Interfaces:
Serializable, opennlp.tools.util.normalizer.CharSequenceNormalizer, opennlp.tools.util.normalizer.OffsetAwareNormalizer
public class ParagraphPreservingWhitespaceCharSequenceNormalizer
extends Object
implements opennlp.tools.util.normalizer.OffsetAwareNormalizer
An
OffsetAwareNormalizer that unwraps hard-wrapped prose while keeping real paragraph
breaks. Within each whitespace run, at most one logical line break (including CRLF as a
single break) collapses to a single space; two or more collapse to one newline
(U+000A). Leading and trailing whitespace is trimmed.
This is the form wanted before sentence detection on Gutenberg-style or other fixed-width
plain text: intra-paragraph line wraps become spaces, blank-line paragraph boundaries survive as
newlines. It reuses the cursor based CharClass.collapseParagraphPreserving(CharSequence, CodePointSet, int) engine, so it recognizes the full Unicode White_Space set with no
regular expression.
For display-oriented text where every line break should survive, use
LineBreakPreservingWhitespaceCharSequenceNormalizer instead. For raw markdown with lists,
code blocks, or other single-newline structure, apply this normalizer only to extracted prose.
- 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
-
ParagraphPreservingWhitespaceCharSequenceNormalizer
public ParagraphPreservingWhitespaceCharSequenceNormalizer()
-
-
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
-