Skip to content Skip to sidebar Skip to footer

How Can I Find The Distance From A Noun To Its Root Node In Word Net?

I want to find how specific a word in my sentence is. So for doing that the assumption that I have taken is the lower a word is in wordnet's hypernym hierarchy it is going to be mo

Solution 1:

Try this...

from nltk.corpus import wordnet as wn
ss = wn.synset('car.n.01')
printmin([len(path) for path in ss.hypernym_paths()])

hypernym_paths() gives you a list of the possible paths back to the root, which for a noun is entity.n.01.

Post a Comment for "How Can I Find The Distance From A Noun To Its Root Node In Word Net?"