Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
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?
If by height you mean depth following a relationship then this might be what are looking for: http://extjwnl.sourceforge.net/javadocs/net/sf/extjwnl/data/relationship/Relationship.html#getDepth()
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".
One way might be to use RelationshipFinder to find the Relationship from "animal" to the root, then use getDepth.
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.
"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);
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)
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 ;)