拼写检查类在code的背后 [英] SpellCheck Class In Code Behind

查看:108
本文介绍了拼写检查类在code的背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来检查拼写落后于code?

Is there a way to check spelling in code behind?

我只可以找到如何使用它的用户界面控件

I only can find how to use it with UI control

<TextBox SpellCheck.IsEnabled="True" Height="20" Width="100"/>

我要的是布尔CheckSpell(串词)

我也不需要一个建议的拼写。

I don't even need a suggested spelling.

这将用来确定在一个文本文件中正确拼写单词的百分比。
一个真正的低一些的文本文件可能不适合供人食用。

This would used to determine the percentage of correctly spelled words in a text file.
A text file with a real low number was probably not intended for human consumption.

该应用程序有SQL后端,所以加载单词列表中Englich词典是一个选项。

The app has SQL back end so loading a list of words in the Englich dictionary is an option.

推荐答案

要解决你的问题,你可以使用 NHunspell 库。

To solve your problem you can use the NHunspell library.

您在这种情况下,检查方法很简单,看起来是这样的:

Your check method in this case is very simple and looks like this:

bool CheckSpell(string word)
{         
    using (Hunspell hunspell = new Hunspell("en_GB.aff", "en_GB.dic"))
    {
        return hunspell.Spell(word);               
    }
}

您可以找到本网站

你也可以使用 拼写检查 类:

Also you can use SpellCheck class:

bool CheckSpell(string word)
{
    TextBox tb = new TextBox();
    tb.Text = word;
    tb.SpellCheck.IsEnabled = true;

    int index = tb.GetNextSpellingErrorCharacterIndex(0, LogicalDirection.Forward);
    if (index == -1)
        return true;
    else
        return false;
}

这篇关于拼写检查类在code的背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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