Created
July 31, 2016 16:08
-
-
Save emckean/2eacb63be35721f25072e1309ad06336 to your computer and use it in GitHub Desktop.
quick python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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