I am trying to extract hypernyms with the wordnet library. However, it is not clear to me how to given a word get the shortest path list of syntnets in order to get its hypernyms. So far I tried this with the help of the documentation:
In:
import wn, wn.taxonomy
lemas_list = []
dog = wn.synsets('katze', pos='n', lang='de')[0]
for path in wn.taxonomy.hypernym_paths(dog):
for i, ss in enumerate(path):
ss.lemmas()
lemas_list.append(ss.lemmas())
lemas_list
However, here I think the first list its wrong ['Tiger', 'Panthera tigris'] as it is not very related to the word katze. Any idea about how to get only the related hypernims?
Out:
[['Tiger', 'Panthera tigris'], ['Katze', 'Felidae']]