Last active
October 9, 2016 15:36
-
-
Save rishabhbhardwaj/e1dfec98c7a8204393a40ac839a255a7 to your computer and use it in GitHub Desktop.
CommandLine-WordOfTheDay
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
#!/usr/bin/env python | |
""" | |
Gives you Word of the Day with its meanings and partOfSpeech. | |
Uses Wordnik. | |
""" | |
import requests, time, json | |
api_key="YOUR_WORDNIK_API_KEY" #Get Here: http://developer.wordnik.com/ | |
date = time.strftime("%Y-%m-%d") | |
wotd_url = "http://api.wordnik.com:80/v4/words.json/wordOfTheDay?date="+date+"&api_key="+api_key | |
wotd_req = requests.get(wotd_url) | |
wotd_json = json.loads(wotd_req.text) | |
wotd_word = wotd_json["word"] | |
print "Word of the Day: " + wotd_word | |
wotd_defs = wotd_json["definitions"] | |
for definition in wotd_defs: | |
cur_def = definition["text"] | |
cur_pos = definition["partOfSpeech"] | |
print " - > Meaning: "+cur_def | |
print " - > partOfSpeech: "+cur_pos | |
""" | |
Add the above code to a file and create an alias in your profile file | |
alias wotd="python ~/path/to/file/" | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment