wordnet.hyponyms()
Syntax
hyponyms(query)
Description
Returns all hyponyms for query. This command generally returns more results than a simple hyponym() command, but queries will run slower since this is a recursive algorithm. The returned value is a list of elements that are themselves a list of related synonyms.
Example
wordnet = ximport("wordnet")
print wordnet.hyponyms("train")
>>>[['train', 'railroad train'], ['boat train'], ['car train'],
>>> ['freight train', 'rattler'], ['freight liner', 'liner train'],
>>> ['hospital train'], ['mail train'], ['passenger train'],
>>> ['commuter', 'commuter train'], ['streamliner'],
>>> ['subway train']]
To get the first synonym of each element in the list, reformat the list as follows:
import wordnet
list = wordnet.hyponyms("train")
list = [element[0] for element in list]
print list
>>>['train', 'boat train', 'car train', 'freight train', 'freight liner',
>>> 'hospital train', 'mail train', 'passenger train', 'commuter',
>>> 'streamliner', 'subway train']