rangeOfMisspelledWordInString查找随机字母作为有效字 [英] rangeOfMisspelledWordInString find random letters as valid word

查看:161
本文介绍了rangeOfMisspelledWordInString查找随机字母作为有效字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以复制这个结果吗?我正在测试 rangeOfMisspelledWordInString (在 iOS 中)查找拼写错误的单词和一些随机字母返回有效单词,如下所示。

Can anybody duplicate this result? I'm testing rangeOfMisspelledWordInString (in iOS) to find mispelled words and some random letters return a valid word as shown below.

UITextChecker* pSpellChecker = [[[UITextChecker alloc] init] autorelease];
NSRange rangeWord = NSMakeRange(0, 8);
NSRange rangeCheck = [_pSpellChecker rangeOfMisspelledWordInString:@"lhpcjeuw"
                                                             range:rangeWord
                                                        startingAt:0
                                                              wrap:NO
                                                          language:@"en_US"];
if (rangeCheck.location == NSNotFound) {
   NSLog(@"Valid Word:");
}

以下是根据rangeOfMisspelledWordInString有效的一些单词:
BTW,我确保在测试之前将以下单词转换为小写。

Below are some of the words that are also valid according to rangeOfMisspelledWordInString: BTW, I've made sure to convert the following words to lowercase before testing.

LD
THY
THE
THECA
TD
HL
HT
YD
YLEQXXH
DV
DVX
DVXX
DVXXD
DVXXDX
DVXXX
DVHXG
DVHEJWCP
DH
DH
DPJLEHHY

非常奇怪。我做错了什么?

Very strange. Am I doing something wrong?

推荐答案

我认为the和你的可能只是有效的词;)

I think "the" and "thy" just might be valid words ;)

除此之外,我最好的猜测是文本系统不能提供单词的猜测,因此完全忽略它 - 拼写错误的单词的语义可能不会包括字母串,这些字母不可能是一个单词拼写错误。我注意到当我在系统文本字段中键入这些字符串时(例如在消息中),我没有得到任何替换建议。

Other than that, my best guess is that the text system can't provide a guess for the word, and so ignores it entirely - the semantic meaning of "misspelled word" might not include "strings of letters which cannot conceivably be a misspelling of a word." I notice that when I type those strings into a system text field (e.g. in Messages), I don't get any replacement suggestions.

您还可以确保UITextChecker实例未设置为忽略这些特定单词;看一下 ignoredWords property

You could also make sure that your UITextChecker instance isn't set to ignore those particular words; take a look at the ignoredWords property.

这篇关于rangeOfMisspelledWordInString查找随机字母作为有效字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆