Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

How to find the height of a node

Help
Danny
2014-02-27
2014-03-03
  • Danny
    Danny
    2014-02-27

    I am using extJWNL to compare words. I am using the example code that comes with the download package. However, I can't seem to figure out how to find the height of a node in the tree. I have been able to get the offset of a particular word. However, if I'm correct, this is only an id for the node. Is there a way to return the height of a word from the root node?

     
    Last edit: Danny 2014-02-27
  • Danny
    Danny
    2014-02-27

    how would I use getDepth to find the depth of a word from the initial root? Is that possible? For example, if I had the word "animal" I would want to find the depth from the very first element in the tree to the word "animal".

    Thanks!

     
  • One way might be to use RelationshipFinder to find the Relationship from "animal" to the root, then use getDepth.

     
  • Danny
    Danny
    2014-03-01

    Is it possible that you could show me an example of how to use the RelationshipFinder to get a relationship? I was also having trouble just getting the very root node.

    Thanks again!

     
  • "Very root" is somewhat vague. WordNet contains many relations and you follow along many of them. However, I guess you refer to isA or hypernymy and if this is true, then perhaps also what call "very root" is an "entity" synset- that which is perceived or known or inferred to have its own distinct existence (living or nonliving). Then maybe something like this is what you are looking for:

            Synset source = ...;
            Synset target = dictionary.getWordBySenseKey("entity%1:03:00::").getSynset();
    
            RelationshipList rl = RelationshipFinder.findRelationships(source, target, PointerType.HYPERNYM);
            rl.getDeepest().getDepth();
    
     
  • Danny
    Danny
    2014-03-03

    That did the trick I think. However, will the same method work for a verb too? For example, if I had the word "ran", would it also be considered an "entity" (ie does the word "ran" have as its root node the "entity" Synset)

    Thanks!

     
  • Danny, why don't you try? Experiment, see the source, open WordNet, take a look around, write a line of code, run see the results ;)