Class RelationshipFinder
- java.lang.Object
-
- net.didion.jwnl.data.relationship.RelationshipFinder
-
public class RelationshipFinder extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static int
DEFAULT_ASYMMETRIC_SEARCH_DEPTH
private static int
DEFAULT_SYMMETRIC_SEARCH_DEPTH
private static RelationshipFinder
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description private
RelationshipFinder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
buildSymmetricRelationshipList(PointerTargetNodeList list, PointerTargetTreeNode node)
Build the relationship.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.private RelationshipList
findAsymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type)
Finds the asymmetric relationship(s) between two words.private RelationshipList
findAsymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth)
Finds the asymmetric relationship(s) between two words.RelationshipList
findRelationships(Synset sourceSynset, Synset targetSynset, PointerType type)
Find all relationships of type type between sourceSynset and targetSynset.RelationshipList
findRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth)
Find all relationships of type type between sourceSynset and targetSynset to depth depth.private PointerTargetNodeList
findSymmetricRelationship(PointerTargetTreeNode node, PointerType type)
Build a relationsip from node back to it's root ancestor and then reverse the list.private RelationshipList
findSymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type)
A symmetric relationship is one whose type is symmetric (i.e.private RelationshipList
findSymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth)
A symmetric relationship is one whose type is symmetric (i.e.int
getImmediateRelationship(IndexWord sourceWord, IndexWord targetWord)
Looks at whether the target word is one of the words in one of the synsets of the source word.static RelationshipFinder
getInstance()
-
-
-
Field Detail
-
DEFAULT_ASYMMETRIC_SEARCH_DEPTH
private static final int DEFAULT_ASYMMETRIC_SEARCH_DEPTH
- See Also:
- Constant Field Values
-
DEFAULT_SYMMETRIC_SEARCH_DEPTH
private static final int DEFAULT_SYMMETRIC_SEARCH_DEPTH
- See Also:
- Constant Field Values
-
INSTANCE
private static final RelationshipFinder INSTANCE
-
-
Method Detail
-
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.
-
-