我正在使用NSLinguisticTagger
课程,我想测试一下丹麦语:
NSString *textToAnalyse = @"Her skal du finde det tal, som mangler";
这个范围包含整个字符串,因为我们想要完全解析它:
NSRange stringRange = NSMakeRange(0, textToAnalyse.length);
// Dictionary with a language map
//NSArray *language = [NSArray arrayWithObjects:@"en",@"de",@"fr",nil];
NSArray *language = [NSArray arrayWithObject:@"da"];
NSDictionary* languageMap = [NSDictionary dictionaryWithObject:language forKey:@"Latn"];
[textToAnalyse enumerateLinguisticTagsInRange:stringRange
scheme:NSLinguisticTagSchemeLexicalClass
options:0
orthography:[NSOrthography orthographyWithDominantScript:@"Latn" languageMap:languageMap]
usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) {
// NSLog(@"%@ is a %@, tokenRange (%d,%d), sentenceRange (%d,%d)",[textToAnalyse substringWithRange:tokenRange] ,tag,tokenRange.length,tokenRange.location, sentenceRange.length, sentenceRange.location);
NSLog(@"%@ is a %@",[textToAnalyse substringWithRange:tokenRange] ,tag);
}]; ...`enter code here`
我找不到...
NSArray *language = [NSArray arrayWithObject:@"da"];
NSDictionary* languageMap = [NSDictionary dictionaryWithObject:language forKey:@"Latn"];
...丹麦语。请告诉我是否有人使用过它或有任何想法。