python - How to handle acronyms in nltk synsets -


am trying synonyms of words. acronyms such who(world health organization), or usa( united states of america) etc. trying escape getting errors acronyms code:

from nltk.corpus import wordnet wn def foo():         s = 'who'         ss = wn.synsets(s)[0]         print [str(x) if list in range in ss else s] foo() 

the problem keep getting error:

s = wn.synsets(ss)[0] indexerror  : list index out of range 

am trying escape getting errors acronyms

problem cannot find synsets 'who', returns empty list, , [0] results in error can see.

try avoiding this

def foo():         s = wn.synsets('who')     if s:         ss = s[0]         print ss 

also, list comprehension doesn't make sense, not part of problem.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -