Im trying to analyse the hypernyms of nouns. when i use the print() method on a PointerTargetTree object i get all the hypernyms out putted to the screen. however when i try to convert the tree to a string using the toString() method all i get is the pointer id number, net.didion.jwnl.data.list.PointerTargetTreeNodeList@d26670.
all i need is the hypernym words, from the given word right up to the final hypernym 'entity' as strings in an array. any idea how i can do this.
many thanks,
john.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Would be possible to get the code for this? I have tried to modify the PointerUtils.makePointerTargetTreeList() function but I have been unable to make it work for Word only.
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Im trying to analyse the hypernyms of nouns. when i use the print() method on a PointerTargetTree object i get all the hypernyms out putted to the screen. however when i try to convert the tree to a string using the toString() method all i get is the pointer id number, net.didion.jwnl.data.list.PointerTargetTreeNodeList@d26670.
all i need is the hypernym words, from the given word right up to the final hypernym 'entity' as strings in an array. any idea how i can do this.
many thanks,
john.
have u tried getting the root node and then iterating the parents/children and calling getWord() --> getLemma() for them?
hi,
yes i have solved this problem now, many thanks.
Dear Marin and John,
can you please forward me a code fragment on how to do this ?
Thanks very much,
Kind regards,
Holger
Dear Holger,
Have you manage to solve the problem? Do you mind posting the code fragments?
Thanks.
Regards,
hlc
Dear all,
I am also looking for the code on how to do this?
Could someone forward it to me please?
Thank you in advance,
Santi.
Hi it's Santi again...........
forgot to write my email address......
superduperlopez@ntlworld.com
Would be possible to get the code for this? I have tried to modify the PointerUtils.makePointerTargetTreeList() function but I have been unable to make it work for Word only.
Thanks
private ArrayList getHypernym( PointerTargetTreeNodeList l, ArrayList p ) throws JWNLException {
ArrayList parent = p;
for (Iterator itr = l.iterator(); itr.hasNext();) {
PointerTargetNode node = (PointerTargetNode) itr.next();
Synset synset = node.getSynset();
String name = synset.getWord(0).getLemma();
parent.add(name);
PointerTargetNodeList targets = new PointerTargetNodeList(synset.getTargets(PointerType.HYPERNYM));
if (targets.size() > 0) {
parent = getHypernymTerm( targets, parent, name);
}
}
return parent;
}
private ArrayList getHypernymTerm( PointerTargetNodeList l, ArrayList p, String s )
throws JWNLException{
ArrayList parent = p;
if ( !s.equals("entity") ) {
for (Iterator itr = l.iterator(); itr.hasNext();) {
PointerTargetNode node = (PointerTargetNode) itr.next();
Synset synset = node.getSynset();
String term = synset.getWord(0).getLemma();
parent.add(term);
PointerTargetNodeList targets = new PointerTargetNodeList(synset.getTargets(PointerType.HYPERNYM) );
if (targets.size() > 0) {
parent = getHypernymTerm( targets, parent, term);
}
}
}
return parent;
}
I managed to get the code working for myself.
Cheers,