Given there is a path from two common synsets to get a lowest common hypernym, it seems reasonable there should be someway to walk back and find the hyponyms that lead to that hypernym
from nltk.corpus import wordnet as wn
alaska = wn.synset('Alaska.n.1')
california = wn.synset('California.n.1')
common_hypernym = alaska.lowest_common_hypernyms(california)[0]
common_hypernym
Synset('american_state.n.01')
common_hypernym.do_something_awesome()
['Alabama.n.1', 'Alaska.n.1', ...] #all 50 american states
Use
Synset1._shortest_path_distance(Synset2)
to find the hypernyms and their distances:Now find the minimum path:
Now, this is boring because
california
andalaska
are sister nodes on the WordNet hierarchy. Let's filter out all sisters nodes:To get the children nodes of the
american_state
(I supposed this is the "something awesome" you need...):This might look shocking but actually, there's no hypernyms indicated for
alaska
orcalifornia
:And the connection made using the
_shortest_hypernym_paths
is by means of a dummy root, take a look at Is wordnet path similarity commutative?