nltk wordnet comprehension madness

use nltk’s wordnet wrapper to pull all the lemma names for each hyponym of all the hyponums for each synonym set for the word “doctor” with the part of speech noun:

>>> [ ([ x.lemma_names for x in list_of_hyponyms if type(x.lemma_names) is type([""]) ]) for list_of_hyponyms in [ synset.hyponyms() for synset in wn.synsets( 'doctor', wn.NOUN ) ]  ]
[[['abortionist'], ['general_practitioner', 'GP'], ['intern', 'interne', 'houseman', 'medical_intern'], ['house_physician', 'resident', 'resident_physician'], ['hakim', 'hakeem'], ['specialist', 'medical_specialist'], ['allergist'], ['quack'], ['angiologist'], ['gastroenterologist'], ['extern', 'medical_extern'], ['veterinarian', 'veterinary', 'veterinary_surgeon', 'vet'], ['surgeon', 'operating_surgeon', 'sawbones']], [], [], []]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: