Class TextNormalizer.Builder
- Enclosing class:
TextNormalizer
CharSequenceNormalizer via build().-
Method Summary
Modifier and TypeMethodDescriptionReturns this builder with script-gated diacritic folding appended.opennlp.tools.util.normalizer.CharSequenceNormalizerbuild()Returns the composed normalizer for the steps added so far.opennlp.tools.util.normalizer.OffsetAwareNormalizerReturns an offset-aware composition of the steps added so far.bullets()Returns this builder with list-bullet replacement appended.caseFold()Returns this builder with case folding appended.dashes()Returns this builder with dash folding appended.digits()Returns this builder with decimal-digit folding appended.ellipsis()Returns this builder with ellipsis expansion appended.Returns this builder with emoji-to-emoticon folding appended.Returns this builder with emoticon-to-emoji folding appended.Returns this builder with Unicode full case folding appended.nfc()Returns this builder with NFC canonical composition appended.nfkc()Returns this builder with NFKC compatibility composition appended.quotes()Returns this builder with quotation-mark folding appended.Returns this builder with invisible/bidi control stripping appended.Returns this builder with Unicode whitespace collapsing appended.Returns this builder with whitespace collapsing that preserves line and paragraph breaks appended.with(opennlp.tools.util.normalizer.CharSequenceNormalizer custom) Appends a custom normalizer.
-
Method Details
-
nfc
Returns this builder with NFC canonical composition appended.- Returns:
- this builder with NFC canonical composition appended
-
nfkc
Returns this builder with NFKC compatibility composition appended.- Returns:
- this builder with NFKC compatibility composition appended
-
stripInvisible
Returns this builder with invisible/bidi control stripping appended.- Returns:
- this builder with invisible/bidi control stripping appended
-
whitespace
Returns this builder with Unicode whitespace collapsing appended.- Returns:
- this builder with Unicode whitespace collapsing appended
-
whitespacePreservingLineBreaks
Returns this builder with whitespace collapsing that preserves line and paragraph breaks appended. Horizontal runs collapse to a single space, but a run containing a line break collapses to a single newline, so paragraph structure survives.- Returns:
- this builder with whitespace collapsing that preserves line and paragraph breaks appended
-
quotes
Returns this builder with quotation-mark folding appended.- Returns:
- this builder with quotation-mark folding appended
-
dashes
Returns this builder with dash folding appended.- Returns:
- this builder with dash folding appended
-
digits
Returns this builder with decimal-digit folding appended.- Returns:
- this builder with decimal-digit folding appended
-
ellipsis
Returns this builder with ellipsis expansion appended.- Returns:
- this builder with ellipsis expansion appended
-
bullets
Returns this builder with list-bullet replacement appended.- Returns:
- this builder with list-bullet replacement appended
-
caseFold
Returns this builder with case folding appended.- Returns:
- this builder with case folding appended
-
fullCaseFold
Returns this builder with Unicode full case folding appended.Applies the full case foldings of
CaseFolding.txtincluding the expanding folds (sharp s toss, the ligatures). It expects composed (NFC) input, since it maps per code point. PrefercaseFold()when the plain lower-case fold is sufficient.- Returns:
- this builder with Unicode full case folding appended
-
accentFold
Returns this builder with script-gated diacritic folding appended.- Returns:
- this builder with script-gated diacritic folding appended
-
emojiToEmoticon
Returns this builder with emoji-to-emoticon folding appended.Folds pictographs with a bundled ASCII emoticon mapping (for example U+1F642 to
:)) and copies everything else through. It is offset-aware, so it composes intobuildAligned().- Returns:
- this builder with emoji-to-emoticon folding appended
-
emoticonToEmoji
Returns this builder with emoticon-to-emoji folding appended.Folds a whitespace-delimited ASCII emoticon to its pictograph (for example
:-)to U+1F642); an emoticon sequence embedded in other text, such as the:/inhttps://, is left alone. Apply before tokenization so emoticons survive as single emoji tokens. It is offset-aware, so it composes intobuildAligned().- Returns:
- this builder with emoticon-to-emoji folding appended
-
with
Appends a custom normalizer.- Parameters:
custom- The normalizer to append. Must not benull.- Returns:
- This builder.
- Throws:
IllegalArgumentException- ifcustomisnull.
-
build
public opennlp.tools.util.normalizer.CharSequenceNormalizer build()Returns the composed normalizer for the steps added so far.- Returns:
- the composed normalizer for the steps added so far
-
buildAligned
public opennlp.tools.util.normalizer.OffsetAwareNormalizer buildAligned()Returns an offset-aware composition of the steps added so far.Every step must be an
OffsetAwareNormalizer. NFC, NFKC, accent folding, confusable folding, and case folding are rejected because they delegate toNormalizeror JDK case mapping and cannot report their per-character edits. The returned normalizer'sOffsetAwareNormalizer.normalizeAligned(CharSequence)maps a span found in the fully normalized text back to the original input through every stage.- Returns:
- an offset-aware composition of the steps added so far
- Throws:
IllegalStateException- if any step cannot report an alignment; the message names the offending step
-