Package opennlp.tools.util.normalizer
Record Class AlignedText
java.lang.Object
java.lang.Record
opennlp.tools.util.normalizer.AlignedText
- Record Components:
original- The untouched source text.normalized- The normalized text.alignment- The alignment between the normalized and original text.
public record AlignedText(CharSequence original, CharSequence normalized, Alignment alignment)
extends Record
The result of a normalization that keeps the original text alongside the normalized form and a
full
Alignment between them.
The original is the source of truth, the normalized form is the derived view tuned for
matching and search, and the alignment maps spans between them through deletions, collapses, and
expansions. Use
toOriginalSpan(int, int) to report a match found in the normalized form against the
original.
-
Constructor Summary
ConstructorsConstructorDescriptionAlignedText(CharSequence original, CharSequence normalized, Alignment alignment) Creates an instance of aAlignedTextrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealignmentrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thenormalizedrecord component.Returns the normalized text as aString.original()Returns the value of theoriginalrecord component.toNormalizedSpan(int originalStart, int originalEnd) Maps a span of the original text forward to the normalized text.toOriginalSpan(int normalizedStart, int normalizedEnd) Maps a span of the normalized text back to the tightest span of the original text.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
AlignedText
Creates an instance of aAlignedTextrecord class.- Parameters:
original- the value for theoriginalrecord componentnormalized- the value for thenormalizedrecord componentalignment- the value for thealignmentrecord component
-
-
Method Details
-
normalizedString
Returns the normalized text as aString.This is the materialized result of the normalization. All implementations build the normalized form via a
StringBuilderand calltoString(), so this is a cheap conversion that does not allocate a new buffer.- Returns:
- The normalized text as an immutable
String.
-
toOriginalSpan
Maps a span of the normalized text back to the tightest span of the original text.- Parameters:
normalizedStart- The inclusive start offset in the normalized text.normalizedEnd- The exclusive end offset in the normalized text.- Returns:
- The corresponding original span.
-
toNormalizedSpan
Maps a span of the original text forward to the normalized text.- Parameters:
originalStart- The inclusive start offset in the original text.originalEnd- The exclusive end offset in the original text.- Returns:
- The corresponding normalized span.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
original
Returns the value of theoriginalrecord component.- Returns:
- the value of the
originalrecord component
-
normalized
Returns the value of thenormalizedrecord component.- Returns:
- the value of the
normalizedrecord component
-
alignment
Returns the value of thealignmentrecord component.- Returns:
- the value of the
alignmentrecord component
-