Guest User

Untitled

a guest
Jan 18th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. from nltk.corpus import wordnet
  2. import time
  3. import pyperclip
  4. import subprocess
  5.  
  6. old_word=""
  7. while(True):
  8. synonyms=[]
  9. time.sleep(2)
  10. new_word=pyperclip.paste()
  11. if(new_word!=old_word):
  12. print(pyperclip.paste())
  13.  
  14. define=wordnet.synsets(new_word)
  15.  
  16. for i in define:
  17. for j in i.lemmas():
  18. synonyms=synonyms+[j.name()]
  19.  
  20. counter=1
  21. definitions=""
  22. for i in define:
  23. message=str(counter)+'. '+i.definition()+'\n'
  24. definitions=definitions+'\n'+message
  25. counter=counter+1
  26.  
  27. synonyms=set(synonyms)
  28. synonyms=', '.join(synonyms)
  29.  
  30. script='\ndisplay dialog "Word meanings are - \n'+definitions+'\n\nSynonyms - \n\n'+synonyms+'" ¬\nwith title "'+new_word+'" ¬\nwith icon caution ¬\nbuttons {"OK"}\n'
  31. subprocess.call("osascript -e '{}'".format(script), shell=True)
  32.  
  33. old_word=pyperclip.paste()
Add Comment
Please, Sign In to add comment