Exception in finding hypernyms

  • Rohit Kochar
    Rohit Kochar

    I am trying to find the relation among two nouns using jwnl and wordnet but whenever i try to use findrelationship() method of class RelationshipFinder i get an NULL Pointer Exception
    This method always throws an exception whenever i try to find 
    HYPERNYM or HYPONYM type of realtion.I am using Wordnet 2.0 and jwnl 1.3.

    The code that i tried is as follows..

    public static void main(String args[])
    IndexWord DOG;
    IndexWord CAT;
    String propsFile = args[0];
    try {
    JWNL.initialize(new FileInputStream(propsFile));
    } catch (Exception ex) {}
    DOG = Dictionary.getInstance().getIndexWord(POS.NOUN, "dog");
    CAT = Dictionary.getInstance().lookupIndexWord(POS.NOUN, "cat");
    RelationshipFinder r=RelationshipFinder.getInstance();
    RelationshipList list =r.findRelationships(CAT.getSense(1), DOG.getSense(1),PointerType.HYPERNYM);
    System.out.println("Hypernym relationship between \"" + DOG.getLemma() + "\" and \"" + CAT.getLemma() + "\":");
    for (Iterator itr = list.iterator(); itr.hasNext();) {
    ((Relationship) itr.next()).getNodeList().print();
    }catch(Exception e){e.printStackTrace();};

    Please help to fix this problem