语言检查中的断言失败

时间:2012-02-01 09:43:23

标签: iphone ios

-(void)testFunction:(NSString *) inputString
{
    NSRange stringRange = NSMakeRange(0, inputString.length);
    NSArray *language = [NSArray arrayWithObjects:@"en",nil];
    NSDictionary* languageMap = [NSDictionary dictionaryWithObject:language forKey:@"Latn"];

    [inputString enumerateLinguisticTagsInRange:stringRange 
                                   scheme:NSLinguisticTagSchemeNameType 
                                  options:(NSLinguisticTaggerOmitWhitespace | NSLinguisticTaggerOmitPunctuation)
                              orthography:[NSOrthography orthographyWithDominantScript:@"Latn" languageMap:languageMap]
                               usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) 
                    {
                        if ([tag isEqualToString:@"PersonalName"]) 
                        {
                            NSLog(@"%@:%@",[inputString substringWithRange:tokenRange] ,tag);
                        }
                    }];
}

我在我的控制台中遇到以下异常,同时激发上述代码  Assertion failed: (output->num_labels == numTokens), function _NSLTTaggerSetResult, file /SourceCache/Foundation_Sim/Foundation-881/Linguistic.subproj/NSLTTagger.m, line 495.

我也没有在我的mac中找到NSLTTagger.m文件。 该函数的主要目的是从给定的文本集中查找人名。

0 个答案:

没有答案