8#import <Foundation/Foundation.h>
12NS_ASSUME_NONNULL_BEGIN
21typedef NS_ENUM(NSInteger, KIOSAlignOp) {
25 KIOSAlignOpSubstitution = 1,
27 KIOSAlignOpInsertion = 2,
29 KIOSAlignOpDeletion = 3,
32#pragma mark - KIOSAlignmentConfig
86#pragma mark - KIOSAlignmentItem
102@property (nonatomic, readonly) KIOSAlignOp
op;
119@property (nonatomic, readonly, copy) NSString *
refToken;
124@property (nonatomic, readonly, copy) NSString *
recToken;
128#pragma mark - KIOSAlignmentResult
144@property (nonatomic, readonly) NSArray<KIOSAlignmentItem *> *
trace;
146#pragma mark Edit-distance counts
149@property (nonatomic, readonly) NSInteger
matches;
173#pragma mark Oral-reading views
211#pragma mark - KIOSTextAligner
259- (nullable instancetype)initWithReference:(NSString *)reference
260 langCode:(NSString *)langCode
261 NS_DESIGNATED_INITIALIZER;
275- (nullable instancetype)initWithReference:(NSString *)reference
278- (instancetype)init NS_UNAVAILABLE;
279+ (instancetype)new NS_UNAVAILABLE;
281#pragma mark Alignment
306#pragma mark Incremental alignment
346#pragma mark Accessors
357@property (nonatomic, readonly, copy) NSString *
langCode;
Per-call configuration for a text-alignment operation.
Definition KIOSTextAligner.h:43
float insertCost
Cost of inserting a recognized token (one not present in the reference).
Definition KIOSTextAligner.h:49
float deleteCost
Cost of deleting a reference token (one not present in the recognized text).
Definition KIOSTextAligner.h:56
BOOL detectRepetitions
When YES, the result populates repetitionRefIndices for words the reader appears to have stuttered or...
Definition KIOSTextAligner.h:73
float substituteCost
Cost of substituting one token for another.
Definition KIOSTextAligner.h:64
BOOL filterNoiseTokens
When YES, recognized tokens whose text begins with '<' (e.g. <SPOKEN_NOISE>, <UNK>) are dropped befor...
Definition KIOSTextAligner.h:82
A single step in an alignment trace.
Definition KIOSTextAligner.h:100
KIOSAlignOp op
The edit operation this item represents.
Definition KIOSTextAligner.h:102
NSInteger recIndex
Index of the recognized token participating in this operation, or NSNotFound for a deletion.
Definition KIOSTextAligner.h:114
NSString * recToken
Recognized token at recIndex, or empty string for a deletion.
Definition KIOSTextAligner.h:124
NSInteger refIndex
Index of the reference token participating in this operation, or NSNotFound for an insertion.
Definition KIOSTextAligner.h:108
NSString * refToken
Reference token at refIndex, or empty string for an insertion.
Definition KIOSTextAligner.h:119
Result of aligning a recognized token sequence against a reference.
Definition KIOSTextAligner.h:142
NSInteger recLength
Length of the post-normalization recognized token vector.
Definition KIOSTextAligner.h:164
NSArray< KIOSAlignmentItem * > * trace
Full alignment trace, left-to-right over the input sequences.
Definition KIOSTextAligner.h:144
NSInteger furthestMatchedIndex
Highest matched reference index, or NSNotFound if no reference token matched.
Definition KIOSTextAligner.h:198
float wordErrorRate
Word error rate: (substitutions + insertions + deletions) / refLength.
Definition KIOSTextAligner.h:171
NSArray< NSNumber * > * matchedRefIndices
Sorted array of reference indices that matched their corresponding recognized token (NSNumber-wrapped...
Definition KIOSTextAligner.h:182
NSInteger insertions
Number of insertions (extra recognized tokens).
Definition KIOSTextAligner.h:155
NSInteger matches
Number of matched token pairs.
Definition KIOSTextAligner.h:149
NSInteger refLength
Length of the post-normalization reference token vector.
Definition KIOSTextAligner.h:161
NSInteger deletions
Number of deletions (skipped reference tokens).
Definition KIOSTextAligner.h:158
NSArray< NSNumber * > * repetitionRefIndices
Reference indices flagged as repetitions in the recognized text (NSNumber-wrapped NSInteger).
Definition KIOSTextAligner.h:207
NSInteger substitutions
Number of substitutions in the alignment.
Definition KIOSTextAligner.h:152
NSArray< NSNumber * > * skippedRefIndices
Sorted array of reference indices that did not match but lie at or below furthestMatchedIndex (NSNumb...
Definition KIOSTextAligner.h:192
Definition KIOSRecognizer.h:347
Aligns recognized speech against a reference text using DP edit distance.
Definition KIOSTextAligner.h:246
NSString * langCode
Language code this aligner was constructed with.
Definition KIOSTextAligner.h:357
NSArray< NSString * > * referenceTokens
Normalized reference tokens, in order. Indices in alignment results refer to positions in this array.
Definition KIOSTextAligner.h:352
void reset()
Drop cached DP state. Call between utterances when using incremental alignment.