将字符串列表与可用的字典/同义词库进行比较
我有一个程序(C#),它生成一个字符串列表(原始字符串的排列)。大多数字符串是按预期随机分组的原始字母(即 etam、aemt、team)。我想以编程方式找到列表中真正的英语单词的一个字符串。我需要一个同义词库/字典来查找和比较每个字符串。任何人都知道可用的资源。我在 C# 中使用 VS2008。
I have a program (C#) that generates a list of strings (permutations of an original string). Most of the strings are random grouping of the original letters as expected (ie etam,aemt, team). I wanna find the one string in the list that is an actual English word, programatically. I need a thesaurus/dictionary to look up and compare each string to. Any one know of a resource available. Im using VS2008 in C#.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以从网络下载单词列表(例如此处提到的文件之一:http:// /www.outpost9.com/files/WordLists.html),然后快速执行以下操作:
You could download a list of words from the web (say one of the files mentioned here: http://www.outpost9.com/files/WordLists.html), then then do a quick:
您还可以使用维基词典。 MediaWiki API(维基百科使用 MediaWiki)允许您查询文章标题列表。在维基词典中,文章标题(除其他外)是词典中的单词条目。唯一的问题是字典中也包含外来词,因此有时您可能会得到“不正确”的匹配。当然,您的用户还需要访问互联网。您可以在以下位置获取有关 api 的帮助和信息: http://en.wiktionary.org/w /api.php
下面是查询 URL 的示例:
这将返回以下 xml:
在 C# 中,您可以使用 System.Xml.XPath 获取所需的部分(具有 pageid 的页面项)。这些才是“真话”。
我编写了一个实现并对其进行了测试(使用上面的简单“狗”示例)。它只返回“狗”和“神”。您应该更广泛地测试它。
像这样称呼它:
我尝试使用 LINQ to XML,但我对它不太熟悉,所以这很痛苦,我放弃了它。
You can also use Wiktionary. The MediaWiki API (Wikionary uses MediaWiki) allows you to query for a list of article titles. In wiktionary, article titles are (among other things) word entries in the dictionary. The only catch is that foreign words are also in the dictionary, so you might get "incorrect" matches sometimes. Your user will also need internet access, of course. You can get help and info on the api at: http://en.wiktionary.org/w/api.php
Here's an example of your query URL:
This returns the following xml:
In C#, you can then use System.Xml.XPath to get the parts you need (page items with pageid). Those are the "real words".
I wrote an implementation and tested it (using the simple "dog" example from above). It returned just "dog" and "god". You should test it more extensively.
Call it like this:
I tried using LINQ to XML, but I'm not that familiar with it, so it was a pain and I gave up on it.