Menu

Coverting PointerTargetTree's to Strings

Help
Anonymous
2003-07-02
2013-04-29
  • Anonymous

    Anonymous - 2003-07-02

    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.

     
    • Marin Dimitrov

      Marin Dimitrov - 2003-07-04

      have u tried getting the root node and then iterating the parents/children and calling getWord() --> getLemma() for them?

       
    • Anonymous

      Anonymous - 2003-07-07

      hi,

      yes i have solved this problem now, many thanks.

       
    • Holger Adelmann

      Holger Adelmann - 2004-02-19

      Dear Marin and John,

      can you please forward me a code fragment on how to do this ?

      Thanks very much,

      Kind regards,

      Holger

       
    • hlc

      hlc - 2004-08-18

      Dear Holger,
      Have you manage to solve the problem?  Do you mind posting the code fragments?

      Thanks.

      Regards,
      hlc

       
    • superduperlopez

      superduperlopez - 2004-08-18

      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.

       
    • superduperlopez

      superduperlopez - 2004-08-18

      Hi it's Santi again...........

      forgot to write my email address......

      superduperlopez@ntlworld.com

       
    • devilspawn

      devilspawn - 2007-06-28

      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

       
    • devilspawn

      devilspawn - 2007-06-28

      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,

       

Log in to post a comment.