NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

wordnet.hypernyms()

Syntax

hypernyms(query)

Description

Returns all hypernyms of query. This command generally returns more results than a simple hypernym() command, but queries will run slower since this is a recursive algorithm. The returned value is a list of elements that are by themselves lists of related synonyms. The last element in the list is the most abstract interpretation of the given query word.

Example

wordnet = ximport("wordnet")
print wordnet.hypernyms("train")
>>>[['train', 'railroad train'], ['public transport'], 
>>> ['conveyance', 'transport'], ['instrumentality', 'instrumentation'],
>>> ['artifact', 'artefact'], ['object', 'physical object'],
>>> ['entity', 'physical thing'], ['whole', 'whole thing', 'unit'],
>>> ['object', 'physical object'], ['entity', 'physical thing']]