【问题标题】:How to check a string against the Windows dictionary?如何根据 Windows 字典检查字符串?
【发布时间】:2014-04-21 16:40:03
【问题描述】:

如何检查某个字符串是否在 Windows 字典中?

或者,换句话说,您如何获取整个 Windows 词典,以便您可以设置一个新词典来包含该内容?

【问题讨论】:

  • 你是在说某种拼写检查字典吗?
  • 是的,我是!用于拼写检查。
  • 您确定 Windows 中有拼写检查字典吗?我知道有一个用于 MS Office,还有一个用于 10 版及更高版本的 Internet Explorer,但这是 Windows 的一部分,还是那些应用程序的一部分?

标签: vb.net .net-4.0 spell-checking


【解决方案1】:

对于 Windows 8 和 Windows Server 2012,有一个 Spelling Checking API,可以通过 COM 从 VB.Net 使用。

Wotsit.org 上列出了指向 Microsoft Word 字典格式(.dic 文件)的链接,遗憾的是该站点当前不可用(提供的链接是通过 Wayback 机器提供的)。

Microsoft 提供了Common Speller API (CSAPI) for Office spell checking,但它似乎需要第三方字典。

Merriam-Webster 提供在线Dictionary API,可免费用于非商业用途。

Microsoft Small Basic 提供了一个Dictionary API 连接到在线服务,可以从 VB.Net 中使用,只需导入 SmallBasicLibrary.dll。

Imports Microsoft.SmallBasic.Library

Module MyModule

    Sub Main()
        Dim definition = Dictionary.GetDefinition("vowel")
        ' A string is returned if the word exists in the dictionary
        Console.WriteLine(CStr(definition))
    End Sub

End Module

【讨论】:

  • 谢谢!使用表单时这也有效吗?还是有不同的表达方式?
  • 另外,有没有办法检查一个词是否在这本词典里?
  • 小型基本字典与环境无关,可在 WPF、WinForms、命令行等中使用。
  • 如果单词不在字典中,小型基本字典将不会返回描述。您可能还想看看 Merriam-Webster Dictionary API(及其他),它似乎具有更复杂的功能。
  • 没问题,另一种可能对性能更好的选择是下载开源词典数据库,请参阅 SO“我在哪里可以下载文本格式的英语词典数据库?” stackoverflow.com/q/6441975/2012417
猜你喜欢
  • 2013-11-12
  • 1970-01-01
  • 2010-12-16
  • 1970-01-01
  • 2017-02-27
  • 2023-03-31
  • 2016-11-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多