getCommonParentIndex causing an exception

Help
2004-02-19
2004-02-23
  • Pat Halogen
    Pat Halogen
    2004-02-19

    Hi,

    I am looping through various senses for certain words trying to find the nearest common parent for each sense pair. I am using the examples code line:

    System.out.println("Common Parent Index: " + ((AsymmetricRelationship) list.get(0)).getCommonParentIndex());

    to get it printed. However, with certain sense-pairs I get an exeption ending in:

    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
            at java.util.ArrayList.RangeCheck(ArrayList.java:507)
            at java.util.ArrayList.get(ArrayList.java:324)
            at net.didion.jwnl.util.TypeCheckingList.get(TypeCheckingList.java:212)

    I noticed that the word sense-pairs that cause that exception do not have a common parent in the WordNet dictionary. For example if you try to get a common parent for the sense of animal, "dog", (the top-node of which is 'entity') with the 'seal' in the sense 'stamp affixed to a document' (the topnode of which is 'abstraction') the above error message is displayed.

    To me it seems that this is a bug in JWNL, but I guess that there is a way of avoiding the above by using some other of the JWNL methods. My question is: How could I elicit the information through JWNL-API that the two senses have no common parents without getting to this error?

    Thanks, ps

     
    • Pat Halogen
      Pat Halogen
      2004-02-23

      Hi,

      I managed to ignore the nodes with no common parents by putting my code within an iterator-loop that checks whether there is any content in the list. However, I feel, JWNL being an API this checking should probably be done in the JWNL code itself. The user should not worry about the structure and failings of the WordNet itself.

      puusee