Full-size dictionary / thesaurus

I am in the early stages of developing a series of simple text games that I hope will help me learn new words. The most important part of the ideas that I have is a completely comprehensible dictionary; I want to be able to use regular expressions to search for a dictionary for given words and extract some other bits of information (e.g. definition, type (noun / verb ...), synonyms, antonyms, quotes demonstrating the word used, etc. ), I currently have a Wordbook (mac app) which I find is ok but didn't understand if I can parse it with a python script. I suppose I can't, and wondered if anyone knew a reasonable dictionary that would allow this. Ideally, I would do all this regardless of the Internet.

thank

+5
source share
3 answers

nltk wordnet corpus provides a programming interface for the "large lexical database of English words." You can navigate the word schedule based on various relationships. It meets the requirements for displaying “definitions, parts of speech, synonyms, antonyms, quotation marks” and “from a dictionary that is perfectly downloadable”.

- , , ( Python).

Wordnet:

import textwrap
from nltk.corpus import wordnet as wn

POS = {
    'v': 'verb', 'a': 'adjective', 's': 'satellite adjective', 
    'n': 'noun', 'r': 'adverb'}

def info(word, pos=None):
    for i, syn in enumerate(wn.synsets(word, pos)):
        syns = [n.replace('_', ' ') for n in syn.lemma_names]
        ants = [a for m in syn.lemmas for a in m.antonyms()]
        ind = ' '*12
        defn= textwrap.wrap(syn.definition, 64)
        print 'sense %d (%s)' % (i + 1, POS[syn.pos])
        print 'definition: ' + ('\n' + ind).join(defn)
        print '  synonyms:', ', '.join(syns)
        if ants:
            print '  antonyms:', ', '.join(a.name for a in ants)
        if syn.examples:
            print '  examples: ' + ('\n' + ind).join(syn.examples)
        print

info('near')

:

sense 1 (verb)
definition: move towards
  synonyms: approach, near, come on, go up, draw near, draw close, come near
  examples: We were approaching our destination
            They are drawing near
            The enemy army came nearer and nearer

sense 2 (adjective)
definition: not far distant in time or space or degree or circumstances
  synonyms: near, close, nigh
  antonyms: far
  examples: near neighbors
            in the near future
            they are near equals
...
+7

Wordnik API- Python

+4

As far as I know, dictionary.com offers a free API for non-commercial use here . You could extract some data from the Internet.

+2
source

All Articles