Bug in findAsymmetricRelationship

Help
2010-11-12
2013-04-29
  • Hello,
    I found a bug in the method
    findAsymmetricRelationship(PointerTargetNodeList sourceNodes, PointerTargetNodeList targetNodes,
        PointerType type, Synset sourceSynset, Synset targetSynset)
    in the class net.didion.jwnl.data.relationship.RelationshipFinder.

    The comparison at the starting of the method:

    // If the deepest ancestors of the words are not the same,
    // then there is no relationship between the words.
    if (!sourceNodes.get(0).equals(targetNodes.get(0))) return null;

    uses the PointerTargetNode objects, so that in some cases (especially in the case that one of the Synset is a top Synset for the given relationship - and so has an empty list for the given relatinship), it returns false also in the case that the deepest ancestor is actually the same Synset.
    This implies that also the method findRelationships of the same class doesn't work well in this cases, giving an empty list not complying the Wordnet structure.

    I fixed this bug moving the comparison from the PointerTargetNode to the relative Synset as follows:

    PointerTargetNode sourceRoot = (PointerTargetNode)sourceNodes.get(0);
        PointerTargetNode targetRoot = (PointerTargetNode)targetNodes.get(0);
    // If the deepest ancestors of the words are not the same,
    // then there is no relationship between the words.
    if (!sourceRoot.getSynset().equals(targetRoot.getSynset()))    
        return null;

    Now all the method appear to work fine also in the cases where one of the input Synset is a top synset for the desired relation.

    I thought that it could be helpful to share this discovering.

    Roberto Interdonato
    Università della Calabria