Get hypernyms/hyponyms using synsetid
Is it possible to pass in a synsetid and get hypernyms or hyponyms? I'm trying to traverse the hierarchy of nouns, and from what I can tell, I need to always pass in "king.n.3" to get a synset. Then use the synset to fetch the hypernyms. Is there a way to do this without having to construct the "king.n.3" string?
Or any other suggestions for going up and down levels of the hierarchy.
I am afraid that this is not yet possible. Right now, you have to construct a string like "king.n.3" to directly obtain a synset. However, any synset obtained from calls to methods like .getHypernyms is again a synset with all the respective methods, so that you can write queries like the following
wn.fetchSynset("entity.n.1", function(err, synset){
synset.getHyponyms().each(function(hyponym){
hyponym.getHyponyms().each(function(hyponym2) {
wn.print(hyponym2);
});
});
});
to retrieve all hyponyms of hyponyms of synset entity, so in that sense you can traverse the levels of the hierarchy. Could you let me know how you would like to retrieve synsets instead of passing in a string like entity.n.1? It would be relatively straight-forward to implement a fetch using the synset id, but I am not sure how useful that would be?
Best,
Philipp