Interface OffsetAwareNormalizer
- All Superinterfaces:
CharSequenceNormalizer,Serializable
CharSequenceNormalizer that can additionally report the Alignment from its
normalized output back to the input, so a span found in the normalized text maps to the exact
character offsets of the original.
Length-changing folds move offsets: collapsing a run of whitespace, folding a supplementary
dash to one ASCII hyphen, or stripping invisible controls all shift every later character. A rung
that performs such a fold over the cursor-based CharClass engine can record those edits
and expose them through normalizeAligned(CharSequence). A rung that delegates to
Normalizer (NFC/NFKC) or to a stemmer cannot report its edits, so it does not
implement this interface; that is a deliberate capability split rather than an oversight.
TextNormalizer.Builder.buildAligned() composes a chain of these into a single
offset-aware pipeline whose AlignedText maps a match all the way back to the original
input. An interface-typed caller tests for the capability
(normalizer instanceof OffsetAwareNormalizer) instead of depending on a concrete rung,
the same plain instanceof pattern used by
OffsetMappingNameFinder (in the DL layer) rather than reflection.
-
Method Summary
Modifier and TypeMethodDescriptionnormalizeAligned(CharSequence text) Normalizestextand returns the result together with theAlignmentback to the input.Methods inherited from interface opennlp.tools.util.normalizer.CharSequenceNormalizer
normalize
-
Method Details
-
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().- Parameters:
text- TheCharSequenceto normalize.- Returns:
- The normalized text paired with its alignment to
text. - Throws:
IllegalArgumentException- Thrown iftextisnull.
-