Class RelationshipFinder

java.lang.Object
net.didion.jwnl.data.relationship.RelationshipFinder

public class RelationshipFinder extends Object
  • Field Details

    • DEFAULT_ASYMMETRIC_SEARCH_DEPTH

      private static final int DEFAULT_ASYMMETRIC_SEARCH_DEPTH
      See Also:
    • DEFAULT_SYMMETRIC_SEARCH_DEPTH

      private static final int DEFAULT_SYMMETRIC_SEARCH_DEPTH
      See Also:
    • INSTANCE

      private static final RelationshipFinder INSTANCE
  • Constructor Details

    • RelationshipFinder

      private RelationshipFinder()
  • Method Details

    • getInstance

      public static RelationshipFinder getInstance()
    • getImmediateRelationship

      public int getImmediateRelationship(IndexWord sourceWord, IndexWord targetWord) throws JWNLException
      Looks at whether the target word is one of the words in one of the synsets of the source word.
      Returns:
      int the sense of the source word that contains the target word
      Throws:
      JWNLException
    • findRelationships

      public RelationshipList findRelationships(Synset sourceSynset, Synset targetSynset, PointerType type) throws JWNLException
      Find all relationships of type type between sourceSynset and targetSynset. This method creates a symmetric or asymmetric relationship based on whether type is symmetric.
      Throws:
      JWNLException
    • findRelationships

      public RelationshipList findRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth) throws JWNLException
      Find all relationships of type type between sourceSynset and targetSynset to depth depth. This method creates a symmetric or asymmetric relationship based on whether type is symmetric.
      Throws:
      JWNLException
    • findAsymmetricRelationships

      private RelationshipList findAsymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type) throws JWNLException
      Finds the asymmetric relationship(s) between two words. A relationship is asymmetric if its type is asymmetric (i.e. it's not its own inverse).
      Throws:
      JWNLException
    • findAsymmetricRelationships

      private RelationshipList findAsymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth) throws JWNLException
      Finds the asymmetric relationship(s) between two words. A relationship is asymmetric if its type is asymmetric (i.e. it's not its own inverse).
      Throws:
      JWNLException
    • findAsymmetricRelationship

      private Relationship findAsymmetricRelationship(PointerTargetNodeList sourceNodes, PointerTargetNodeList targetNodes, PointerType type, Synset sourceSynset, Synset targetSynset)
      Find a relationship between two asymmetric lists ordered from deepest to shallowest ancestor. Each node has it's PointerType set to the kind of relationship one need to follow to get from it to the next node in the list. Take the dog/cat relationship. To get to carnivore, a hypernym relationship must be used to get from dog to carnivore, but then a hyponym relationship must be used to get from carnivore to cat. The list will look like this: dog(hyper) -> canine(hyper) -> carnivore(hypo) -> feline(hypo) -> cat(hypo). In this instance, cat's PointerType is meaningless, but is kept to facilitate things like reversing the relationship (which just involves setting each node's pointer type to the symmetric type of its current type.
    • findSymmetricRelationships

      private RelationshipList findSymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type) throws JWNLException
      A symmetric relationship is one whose type is symmetric (i.e. is it's own inverse. An example of a symmetric relationship is synonomy.
      Throws:
      JWNLException
    • findSymmetricRelationships

      private RelationshipList findSymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth) throws JWNLException
      A symmetric relationship is one whose type is symmetric (i.e. is it's own inverse).
      Throws:
      JWNLException
    • findSymmetricRelationship

      private PointerTargetNodeList findSymmetricRelationship(PointerTargetTreeNode node, PointerType type)
      Build a relationsip from node back to it's root ancestor and then reverse the list.
    • buildSymmetricRelationshipList

      private void buildSymmetricRelationshipList(PointerTargetNodeList list, PointerTargetTreeNode node)
      Build the relationship.