Python module with access to english dictionaries including definitions of words

32,260

Solution 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."

Solution 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]

Solution 3

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

Solution 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)

Solution 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.

Share:
32,260

Related videos on Youtube

Sadık
Author by

Sadık

CV

Updated on April 01, 2020

Comments

  • Sadık
    Sadık about 4 years

    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?

    • Namey
      Namey about 10 years
      A big question for this: Do you need a module that works offline, or can it be an API into a web-service? To be quite frank, having a program port around a comprehensive English dictionary seems like overkill for most applications I can think of. Plus, using one of those, you could always easily build a mini-dictionary to package with your application (provided the licensing terms allow it).
    • Namey
      Namey about 10 years
      For example, Wikitionary: stackoverflow.com/questions/2770547/…
    • Sadık
      Sadık about 10 years
      if possible, it should work without web access
  • Sadık
    Sadık about 10 years
    It's not exactly what I am looking for. As I said: I need also dictionary entries for common words like "could", "can", "I", "you".... and so on. These are not part of WordNet. But if there were another helpful nltk.corpus it would be great.
  • abnry
    abnry almost 10 years
    This is great. It's the best formatted dictionary I've been looking for that I can simply download.
  • jayelm
    jayelm over 7 years
    @uoɥʇʎPʎzɐɹC fixed.