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 intDEFAULT_ASYMMETRIC_SEARCH_DEPTHprivate static intDEFAULT_SYMMETRIC_SEARCH_DEPTHprivate static RelationshipFinderINSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description privateRelationshipFinder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidbuildSymmetricRelationshipList(PointerTargetNodeList list, PointerTargetTreeNode node)Build the relationship.private RelationshipfindAsymmetricRelationship(PointerTargetNodeList sourceNodes, PointerTargetNodeList targetNodes, PointerType type, Synset sourceSynset, Synset targetSynset)Find a relationship between two asymmetric lists ordered from deepest to shallowest ancestor.private RelationshipListfindAsymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type)Finds the asymmetric relationship(s) between two words.private RelationshipListfindAsymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth)Finds the asymmetric relationship(s) between two words.RelationshipListfindRelationships(Synset sourceSynset, Synset targetSynset, PointerType type)Find all relationships of type type between sourceSynset and targetSynset.RelationshipListfindRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth)Find all relationships of type type between sourceSynset and targetSynset to depth depth.private PointerTargetNodeListfindSymmetricRelationship(PointerTargetTreeNode node, PointerType type)Build a relationsip from node back to it's root ancestor and then reverse the list.private RelationshipListfindSymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type)A symmetric relationship is one whose type is symmetric (i.e.private RelationshipListfindSymmetricRelationships(Synset sourceSynset, Synset targetSynset, PointerType type, int depth)A symmetric relationship is one whose type is symmetric (i.e.intgetImmediateRelationship(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 RelationshipFindergetInstance()
-
-
-
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.
-
-