将拼写检查器添加到我的词典(Windows应用程序) [英] adding spell checker to my dictionary (windows application)

查看:83
本文介绍了将拼写检查器添加到我的词典(Windows应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.
我有一个词典项目,可以将单词从英语翻译成我的语言,并且我想在用户输入文本框时添加拼写检查器,例如,当用户在文本框下拉菜单中输入 hel 并对所有关闭的单词进行排序时到 hel
任何帮助将不胜感激.
谢谢.
BR.

Hi.
i have a dictionary project to translate words from english to my language and i want to add spell checker while user typing in a textbox for example when user write hel the textbox dropdown and sort all the words that are close to hel
any help will be appreciated.
thanks.
BR.

推荐答案

你好

假设您有一个这样的字典:

Hello

Imagine you have a dictionay like this:

Dictionary<string,> dictionary = new Dictionary<string,>();

dictionary.Add("book", new string[3] { "libro", "libretto", "blocchetto" });
dictionary.Add("student", new string[2] { "studente", "allievo" });



然后使用此方法:




then use this method:


private bool FindWord(string word, Dictionary<string,> dictionary)
{
   var found = from key in dictionary.Keys
      where key.ToLower() == word.ToLower()
          select key;

   return (found.Count() == 0) ? false : true;
}



然后:



then:

string word = "boock";

Dictionary<string, string> replacedLetters = new Dictionary<string, string>();
replacedLetters.Add("ck", "k");
replacedLetters.Add("l", "ll");
replacedLetters.Add("k", "ck");
replacedLetters.Add("ll", "l");
replacedLetters.Add("ou", "oo");
replacedLetters.Add("oo", "ou");
replacedLetters.Add("ee", "ea");
replacedLetters.Add("ea", "ee");


List<string> suggestionList = new List<string>();

foreach (string s in replacedLetters.Keys)
{
    string replacedWord = word.ToLower().Replace(s, replacedLetters[s]);

    if (FindWord(replacedWord, dictionary))
        suggestionList.Add(replacedWord);
}



您必须对其进行处理才能获得更好的结果.



You must work on it for a better result.


首先,我建议您使用以下搜索方式搜索CodeProject:[ ^ ],并找到可能有用的文章,例如:[ ^ ].

然后,如果这是WinForms,请考虑ComboBox的自动下拉单词补全功能及其"AutoCompleteMode和" AutoCompleteSource,以及"AutoCompleteCustomSource"属性.查看MSDN文档:[ ^ ].

当然,还可以在CP上搜索有关ComboBox和Auto-Complete属性的有用文章:[ ^ ]?
First, I suggest you search CodeProject, with searches like these: [^] and [^], and locate potentially useful articles like this one:[^].

Then, if is this is WinForms, consider the automatic dropdown word completion feature of the ComboBox, and its ''AutoCompleteMode and ''AutoCompleteSource, and ''AutoCompleteCustomSource properties. Look at the MSDN docs: [^].

And, of course, search CP for helpful articles on ComboBox and Auto-Complete properties: [^], and [^].

Like this one: [^] ?


这篇关于将拼写检查器添加到我的词典(Windows应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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