3

How can I know the maximum depth of the taxonomy for wordnet 3.0? (is-a relationships for synsets)

I read some papers and found from a paper that it is 16 for wordnet 1.7.1.

I'm wondering the value for wordnet 3.0.

1 Answers1

5

You can try the wordnet interface in python nltk.

Iterate through each synset in wordnet and find the distance to their top most hypernym:

>>> from nltk.corpus import wordnet
>>> from nltk.corpus import wordnet as wn
>>> max(max(len(hyp_path) for hyp_path in ss.hypernym_paths()) for ss in wn.all_synsets())
20

To find the possible paths of a synset to its top most hypernym:

>>> wn.synset('dog.n.1')
Synset('dog.n.01')
>>> wn.synset('dog.n.1').hypernym_paths()
[[Synset('entity.n.01'), Synset('physical_entity.n.01'), Synset('object.n.01'), Synset('whole.n.02'), Synset('living_thing.n.01'), Synset('organism.n.01'), Synset('animal.n.01'), Synset('chordate.n.01'), Synset('vertebrate.n.01'), Synset('mammal.n.01'), Synset('placental.n.01'), Synset('carnivore.n.01'), Synset('canine.n.02'), Synset('dog.n.01')], [Synset('entity.n.01'), Synset('physical_entity.n.01'), Synset('object.n.01'), Synset('whole.n.02'), Synset('living_thing.n.01'), Synset('organism.n.01'), Synset('animal.n.01'), Synset('domestic_animal.n.01'), Synset('dog.n.01')]]

To find the maximum of one synset:

>>> max(len(hyp_path) for hyp_path in wn.synset('dog.n.1').hypernym_paths())
14
alvas
  • 115,346
  • 109
  • 446
  • 738
  • Isn't a cached-like version of this heavy computation? – Marco Ottina Oct 22 '19 at 13:05
  • Nope, it's actually very very compute friendly compared to neural things ;P – alvas Oct 23 '19 at 01:20
  • ok, but I mean: WordNet is almost fixed, it's not a structure heavily dynamic, so useful information like "the lowes / highest depth" should be cached. Compute the max of all possible path it's asymptotically heavy (not for the "max" part, you know). That's why I suggest caching the result. In fact, that's what I do in my university's project: map word->depth (= – Marco Ottina Oct 26 '19 at 11:47