Skip to content

Instantly share code, notes, and snippets.

@davehouse
Created January 15, 2020 05:40
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 davehouse/ce0bfc3b2d951f0213900e45e5ff7c8d to your computer and use it in GitHub Desktop.
Save davehouse/ce0bfc3b2d951f0213900e45e5ff7c8d to your computer and use it in GitHub Desktop.
bash local dictionary using wordnet+python
# source or copy this in your .bashrc or where you keep your shell functions
function dict() {
python -c "from nltk.corpus import wordnet as wn;import json;\
print(json.dumps({x.name(): [x.definition()] + x.examples() \
for x in wn.synsets('$1')},indent=2))" \
|| echo -e "\nSetup python NLTK + WordNet like:
pip install nltk && python -c \"import nltk; nltk.download('wordnet')\""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment