Python module with access to english dictionaries including definitions of words [closed]

随声附和 提交于 2019-12-20 08:33:26

问题


I am looking for a python module that helps me get the definition(s) from an english dictionary for a word.

There is of course enchant, which helps me check if the word exists in the English language, but it does not provide definitions of them (at least I don't see anything like that in the docs)

There is also WordNet, which is accessible with NLTK. It has definitions and even sample sentences, but WordNet does not contain all English words. Common words like "how", "I", "You", "should", "could"... are not part of WordNet.

Is there any python module that gives access to a full english dictionary including definitions of words?


回答1:


Wordnik seems to have quite a nice API, and a nice-looking Python module too. It has definitions, example sentences, etc. so you should be covered. It does also have common words like "how", "should", and "could."




回答2:


Instead of a module, you can rely other offline/online sources like xml,json,api etc.

  1. https://github.com/adambom/dictionary [json file]

  2. http://dictionary-api.cambridge.org [REST api]

  3. http://glosbe.com/a-api [REST api]

  4. http://developer.oxforddictionaries.com/developer-resources/api-reference-guide/intro-using-the-oxford-dictionaries-api/ [REST api]

  5. http://www.ibiblio.org/webster/ [XML, open source]




回答3:


What about this. You'll need to write your own parser, but that should be fairly trivial given how the data is formatted.




回答4:


Note that while WordNet does not have all English words, what about the Oxford English Dictionary? (http://developer.oxforddictionaries.com/). Depending on the scope of your project, it could be a killer API.

Have you tried looking at Grady Ward's Moby? [link] (http://icon.shef.ac.uk/Moby/).

You could add it as a lexicon in NLTK (see notes on "Loading your own corpus" in Section 2.1).

from nltk.corpus import PlaintextCorpusReader
corpus_root = '/usr/share/dict'
wordlists = PlaintextCorpusReader(corpus_root, '.*')

Or:

from nltk.corpus import BracketParseCorpusReader
corpus_root = r"C:\corpora\penntreebank\parsed\mrg\wsj"
file_pattern = r".*/wsj_.*\.mrg"
ptb = BracketParseCorpusReader(corpus_root, file_pattern)



回答5:


The python NLTK has a WordNet interface which is exactly what you're looking for. http://www.nltk.org/howto/wordnet.html

Edit: OP did not specify his request for common words, thus ruling out WordNet, until after I posted this answer. Since this answer has upvotes anyways, I'll leave it here.



来源:https://stackoverflow.com/questions/21395011/python-module-with-access-to-english-dictionaries-including-definitions-of-words

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!