【发布时间】:2014-08-15 15:32:04
【问题描述】:
我正在使用NSLinguisticTagger 进行词干提取。我可以得到一个句子中单词的词干,但不能得到一个词的词干。
以下是我正在使用的代码,
NSString *stmnt = @"i waited";
NSLinguisticTaggerOptions options = NSLinguisticTaggerOmitWhitespace | NSLinguisticTaggerOmitPunctuation | NSLinguisticTaggerJoinNames;
NSLinguisticTagger *tagger = [[NSLinguisticTagger alloc] initWithTagSchemes:@[NSLinguisticTagSchemeLemma] options:options];
tagger.string = stmnt;
[tagger enumerateTagsInRange:NSMakeRange(0, [stmnt length]) scheme:NSLinguisticTagSchemeLemma options:options usingBlock:^(NSString *tag, NSRange tokenRange, NSRange sentenceRange, BOOL *stop) {
NSString *token = [stmnt substringWithRange:tokenRange];
NSLog(@"%@: %@", token, tag);
}];
为此,我正确地退出了:
i: i
waited: wait
但是如果stmnt = @"waited";上面的代码无法识别词干
非常感谢任何帮助
【问题讨论】:
标签: ios iphone objective-c linguistics