Skip to content

Instantly share code, notes, and snippets.

@emckean
Created July 31, 2016 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emckean/2eacb63be35721f25072e1309ad06336 to your computer and use it in GitHub Desktop.
Save emckean/2eacb63be35721f25072e1309ad06336 to your computer and use it in GitHub Desktop.
quick python
from wordnik import *
apiUrl = 'http://api.wordnik.com/v4'
apiKey = 'YOUR KEY HERE'
client = swagger.ApiClient(apiKey, apiUrl)
wordApi = WordApi.WordApi(client)
res = wordApi.getWord('cat')
// you need to call getDefinitions on a word, as the part of speech lives at the definition level:
res2 = wordApi.getDefinitions('cat')
assert res, 'null getWord result'
assert res.word == 'cat', 'word should be "cat"'
print res.word
// getDefinitions returns a list, each item in the list will have a partOf Speech:
print dir(res2[0])
print res2[0].partOfSpeech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment