我正在使用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"];...for丹麦语如果有人用过或者有什么想法,请告诉我。
发布于 2012-07-06 22:47:45
它并不存在。对于iOS,由于空间限制,目前仅支持英语。
https://stackoverflow.com/questions/9633548
复制相似问题