Class ParagraphPreservingWhitespaceCharSequenceNormalizer

java.lang.Object
opennlp.tools.util.normalizer.ParagraphPreservingWhitespaceCharSequenceNormalizer
All Implemented Interfaces:
Serializable, CharSequenceNormalizer, OffsetAwareNormalizer

public class ParagraphPreservingWhitespaceCharSequenceNormalizer extends Object implements 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.

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: