Class KASRAlignmentResult

java.lang.Object
com.keenresearch.keenasr.KASRAlignmentResult

public class KASRAlignmentResult extends Object
Result of aligning a recognized token sequence against a reference. Exposes both an edit-script trace (suitable for word-error-rate reporting) and derived oral-reading views (matched / skipped / furthest-reached). Indices in *RefIndices accessors and getFurthestMatchedIndex() refer to positions in the normalized reference token vector, accessible via KASRTextAligner.getReferenceTokens(). Instances of this class are immutable and constructed via JNI from a native keenasr::AlignmentResult. Indices use -1 (not Integer.MIN_VALUE or similar) for the "no value" sentinel.
  • Method Details

    • getTrace

      public final List<KASRAlignmentItem> getTrace()
      Returns:
      Full alignment trace, left-to-right over the input sequences.
    • getMatches

      public final int getMatches()
      Returns:
      Number of matched token pairs.
    • getSubstitutions

      public final int getSubstitutions()
      Returns:
      Number of substitutions in the alignment.
    • getInsertions

      public final int getInsertions()
      Returns:
      Number of insertions (extra recognized tokens).
    • getDeletions

      public final int getDeletions()
      Returns:
      Number of deletions (skipped reference tokens).
    • getRefLength

      public final int getRefLength()
      Returns:
      Length of the post-normalization reference token vector.
    • getRecLength

      public final int getRecLength()
      Returns:
      Length of the post-normalization recognized token vector.
    • getWordErrorRate

      public final float getWordErrorRate()
      Returns:
      Word error rate: (substitutions + insertions + deletions) / refLength. Returns 0.0 when refLength is 0.
    • getMatchedRefIndices

      public final int[] getMatchedRefIndices()
      Returns:
      Sorted array of reference indices that matched their corresponding recognized token. Substitutions and deletions are not counted — only exact-word matches.
    • getSkippedRefIndices

      public final int[] getSkippedRefIndices()
      Returns:
      Sorted array of reference indices that did not match but lie at or below getFurthestMatchedIndex(). Reference tokens past the furthest-matched index are treated as "not yet reached" and excluded here.
    • getFurthestMatchedIndex

      public final int getFurthestMatchedIndex()
      Returns:
      Highest matched reference index, or -1 if no reference token matched.
    • getRepetitionRefIndices

      public final int[] getRepetitionRefIndices()
      Returns:
      Reference indices flagged as repetitions in the recognized text. Populated only when KASRAlignmentConfig.detectRepetitions was true on the call that produced this result.