]>
Commit | Line | Data |
---|---|---|
685e346e A |
1 | from wordnik import * |
2 | ||
3 | class Words(object): | |
4 | apiUrl = "http://api.wordnik.com/v4" | |
5 | ||
6 | def __init__(self, key): | |
7 | self.wordnik = WordApi.WordApi(swagger.ApiClient(key, self.apiUrl)) | |
8 | self.last_def = {} | |
9 | ||
10 | def definition(self, word): | |
11 | if word in self.last_def: | |
12 | return self.last_def[word] | |
13 | ||
14 | defs = self.wordnik.getDefinitions(word, sourceDictionaries='ahd', useCanonical=True, includeTags=False) | |
15 | ||
16 | self.last_def = {word: defs} | |
17 | return defs |