【问题标题】:Word interop spell checking (determining when a word is spelled correctly)单词互操作拼写检查(确定单词何时拼写正确)
【发布时间】:2015-03-24 19:25:27
【问题描述】:

我正在使用 Word 的拼写检查器来发布 OCR,这在很大程度上要感谢 Spell Checking in C# Using Word Interop 我已经让整个事情在原则上正常工作。

我的问题是区分拼写正确的单词和单词拼写检查器没有建议的随机垃圾字符序列。

foreach(string s in textBox1.Text.Split(' '))
{
    if(s.Length > 0)
    {
        //Get suggestions for this 'word'
        var suggestions = app.GetSpellingSuggestions(s, custDict, MainDictionary: Word.WdLanguageID.wdEnglishUK);

        //There is no suggestion, displays correctly spelled words and random nonsense for which word has no suggestion.
        if(suggestions.Count == 0)
        {
            MessageBox.Show(s);
        }

        foreach (Word.SpellingSuggestion spellingSuggestion in suggestions)
        {
            //Display the best suggestion then break.
            if (suggestions.Count > 0)
            {
                MessageBox.Show(spellingSuggestion.Name);
                break;
            }
        }
    }   
}

是否有某种机制来确定建议的“分数”或区分字典中存在的字符串和不存在的字符串?

提前致谢。

【问题讨论】:

  • 如果你想通了,你可以回答你自己的问题:)

标签: c# winforms interop spell-checking


【解决方案1】:

对于遇到同样问题的其他人,您可以使用 SpellingErrorType 枚举来发现该字符串是否存在于字典中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-30
    • 2011-05-28
    • 1970-01-01
    • 2020-10-26
    • 2013-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多