完全可解析的词典/同义词库
我正处于设计一系列简单文字游戏的早期阶段,我希望这些游戏能帮助我学习新单词。我的想法的一个关键部分是一个完全可解析的字典;我希望能够使用正则表达式在字典中搜索给定的单词并提取某些其他信息(例如定义、类型(名词/动词...)、同义词、反义词、演示正在使用的单词的引号等) 。我目前有 Wordbook(mac 应用程序),我觉得还可以,但还没有弄清楚是否可以使用 python 脚本解析它。我假设我不能,并且想知道是否有人知道一本合理的字典可以实现这一点。理想情况下,我会独立于互联网完成所有这些工作。
谢谢
I'm in the early stages of designing a series of simple word games which I hope will help me learn new words. A crucial part of the ideas that I have is a fully parsable dictionary; I want to be able to use regular expressions to search the dictionary for given words and extract certain other bits of information (e.g. definition, type (noun/verb...), synonyms, antonyms, quotes demonstrating the word in use, etc). I currently have Wordbook (mac app) which I find okay, but haven't figured out if I can parse it using a python script. I'm assuming I can't, and was wondering if anyone knows of a reasonable dictionary that will allow this. Ideally I would do all this independent of the internet.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
nltk wordnet 语料库 为“大型英语单词词汇数据库”提供了编程接口。您可以根据各种关系浏览词图。它满足显示“定义、词性、同义词、反义词、引用”和“来自理想可下载的词典”的要求。
另一种选择是下载维基词典数据的最新快照并将其解析为您可以使用的格式,但这可能是一个有点涉及(<a href="http://code.google.com/p/wiktionary-parser/">除非已经存在一个像样的 Python Wiktionary 解析器)。
下面是使用 Wordnet 打印一些属性的示例:
输出:
The nltk wordnet corpus provides a programmatic interface to a "large lexical database of English words". You can navigate the word graph based on a variety of relationships. It meets the requirements for showing "definition, part-of-speech, synonyms, antonyms, quotes", and "from a dictionary which is ideally downloadable".
Another option would be to download a recent snapshot of Wiktionary data and parse it into a format you can use, but this may be a bit involved (unless a decent Python Wiktionary parser already exists).
Here is an example of printing out some attributes using Wordnet:
Output:
Wordnik 有一个 Python API
Wordnik has a Python API
据我所知,dictionary.com 在此处提供了一个用于非商业用途的免费 API。您也许可以从互联网上获取一些数据。
To my knowledge, dictionary.com offers a free API for noncommercial use here. You might be able to pull some of the data off the internet.