gpt4 book ai didi

objective-c - NSLinguisticTagger 语言是 "und"

转载 作者:搜寻专家 更新时间:2023-10-30 20:09:15 24 4
gpt4 key购买 nike

我正在尝试找出字符串的语言。如果我从变量传递它,它会将语言识别为“und”,但如果我将它传递为

 [tagger setString:[NSString stringWithFormat:@"Example 2 Three people have attached a rope around your belly and pull it with the indicated forces. The sketch isn’t true to scale and shows the situation froth above. a) Detennine with a drawing, in what direction you are pulled (assuming that you don’t put up any resistance) Choose a scale of l00N 2 Ion . b) What is the influence of the lengths of the ropes?"]];

它能正确识别语言。两种情况下的文本相同

//Recognize Language for Output
{
NSArray *tagschemes = [NSArray arrayWithObjects:NSLinguisticTagSchemeLanguage, nil];
NSLinguisticTagger *tagger = [[NSLinguisticTagger alloc] initWithTagSchemes:tagschemes options:0];
[tagger setString:[NSString stringWithFormat:@"%@", text]];

NSString *language = [tagger tagAtIndex:0 scheme:NSLinguisticTagSchemeLanguage tokenRange:NULL sentenceRange:NULL];

output = [NSString stringWithFormat:@"The language is %@\rand the following words were found:\r\r%@", language, output];

}

“und”是什么语言,为什么它不能正确地将语言识别为 en?

最佳答案

来自 the docs对于 NSOrthography:

如果无法确定特定语言,则使用标签 und

关于objective-c - NSLinguisticTagger 语言是 "und",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21411626/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com