更新时间:2022-06-16 21:17:05
以下代码适用于我,
NSString *stmt = @"waited";
NSRange stringRange = NSMakeRange(0, stmt.length);
NSDictionary* languageMap = @{@"Latn" : @[@"en"]};
[stmt enumerateLinguisticTagsInRange:stringRange
scheme:NSLinguisticTagSchemeLemma
options:NSLinguisticTaggerOmitWhitespace
orthography:[NSOrthography orthographyWithDominantScript:@"Latn" languageMap:languageMap]
usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) {
// Log info to console for debugging purposes
NSString *currentEntity = [stmt substringWithRange:tokenRange];
NSLog(@"%@ is a %@, tokenRange (%d,%d)",currentEntity,tag,tokenRange.length,tokenRange.location);
}];