/** * Get the depth of this relationship. Depth is a concept that can be defined by each relationship type. * The default notion of depth is the number of pointers that need to be traversed to go from the source * to target synset. This is basically getSize() - 1. */ public int getDepth() { return getSize() - 1; }
/** * 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). */ private RelationshipList findAsymmetricRelationships( Synset sourceSynset, Synset targetSynset, PointerType type) throws JWNLException { return findAsymmetricRelationships(sourceSynset, targetSynset, type, DEFAULT_ASYMMETRIC_SEARCH_DEPTH); }
/** Return the deepest Relationship in the list. */ public synchronized Relationship getDeepest() { if (_deepestIndex >= 0) { return (Relationship)get(_deepestIndex); } return null; } }
private void demonstrateAsymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException { // Try to find a relationship between the first sense of <var>start</var> and the first sense of <var>end</var> RelationshipList list = RelationshipFinder.getInstance().findRelationships(start.getSense(1), end.getSense(1), PointerType.HYPERNYM); System.out.println("Hypernym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Iterator itr = list.iterator(); itr.hasNext();) { ((Relationship) itr.next()).getNodeList().print(); } System.out.println("Common Parent Index: " + ((AsymmetricRelationship) list.get(0)).getCommonParentIndex()); System.out.println("Depth: " + ((Relationship) list.get(0)).getDepth()); }
public int getSize() { return getNodeList().size(); }
/** Two relationships are assumed equal if they have the same source synset, target synset, and type */ public boolean equals(Object obj) { if (obj instanceof Relationship) { Relationship r = (Relationship) obj; return r.getType().equals(getType()) && r.getSourceSynset().equals(getSourceSynset()) && r.getTargetSynset().equals(getTargetSynset()); } return false; }
/** * Find all relationships of type <var>type</var> between <var>sourceSynset</var> and <var>targetSynset</var>. * This method creates a symmetric or asymmetric relationship based on whether <var>type</var> is symmetric. */ public RelationshipList findRelationships( Synset sourceSynset, Synset targetSynset, PointerType type) throws JWNLException { return (type.isSymmetric()) ? findSymmetricRelationships(sourceSynset, targetSynset, type) : findAsymmetricRelationships(sourceSynset, targetSynset, type); }
/** * A symmetric relationship is one whose type is symmetric (i.e. is it's own * inverse. An example of a symmetric relationship is synonomy. */ private RelationshipList findSymmetricRelationships( Synset sourceSynset, Synset targetSynset, PointerType type) throws JWNLException { return findSymmetricRelationships(sourceSynset, targetSynset, type, DEFAULT_SYMMETRIC_SEARCH_DEPTH); }
/** * Get the depth of the target, from the commonParentIndex, relative to the depth of the source. * If both target and source are eqidistant from the commonParentIndex, this method returns 0; */ public int getRelativeTargetDepth() { if (_cachedRelativeTargetDepth == -1) { int distSourceToParent = _commonParentIndex; int distParentToTarget = (getNodeList().size() - 1) - _commonParentIndex; _cachedRelativeTargetDepth = distParentToTarget - distSourceToParent; } return _cachedRelativeTargetDepth; }
/** * Build a relationsip from <var>node</var> back to it's root ancestor and * then reverse the list. */ private PointerTargetNodeList findSymmetricRelationship(PointerTargetTreeNode node, PointerType type) { PointerTargetNodeList list = new PointerTargetNodeList(); buildSymmetricRelationshipList(list, node); list = list.reverse(); // set the root's pointer type ((PointerTargetNode)list.get(0)).setType(type); return list; }
private void demonstrateAsymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException { // Try to find a relationship between the first sense of <var>start</var> and the first sense of <var>end</var> RelationshipList list = RelationshipFinder.getInstance().findRelationships(start.getSense(1), end.getSense(1), PointerType.HYPERNYM); System.out.println("Hypernym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Iterator itr = list.iterator(); itr.hasNext();) { ((Relationship) itr.next()).getNodeList().print(); } System.out.println("Common Parent Index: " + ((AsymmetricRelationship) list.get(0)).getCommonParentIndex()); System.out.println("Depth: " + ((Relationship) list.get(0)).getDepth()); }
/** Return the shallowest Relationship in the list. */ public synchronized Relationship getShallowest() { if (_shallowestIndex >= 0) { return (Relationship)get(_shallowestIndex); } return null; }
/** * Find all relationships of type <var>type</var> between <var>sourceSynset</var> and <var>targetSynset</var> * to depth <var>depth</var>. This method creates a symmetric or asymmetric relationship based on * whether <var>type</var> is symmetric. */ public RelationshipList findRelationships( Synset sourceSynset, Synset targetSynset, PointerType type, int depth) throws JWNLException { return (type.isSymmetric()) ? findSymmetricRelationships(sourceSynset, targetSynset, type, depth) : findAsymmetricRelationships(sourceSynset, targetSynset, type, depth); }
private void demonstrateAsymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException { // Try to find a relationship between the first sense of <var>start</var> and the first sense of <var>end</var> RelationshipList list = RelationshipFinder.getInstance().findRelationships(start.getSense(1), end.getSense(1), PointerType.HYPERNYM); System.out.println("Hypernym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Iterator itr = list.iterator(); itr.hasNext();) { ((Relationship) itr.next()).getNodeList().print(); } System.out.println("Common Parent Index: " + ((AsymmetricRelationship) list.get(0)).getCommonParentIndex()); System.out.println("Depth: " + ((Relationship) list.get(0)).getDepth()); }
private void demonstrateAsymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException { // Try to find a relationship between the first sense of <var>start</var> and the first sense of <var>end</var> RelationshipList list = RelationshipFinder.getInstance().findRelationships(start.getSense(1), end.getSense(1), PointerType.HYPERNYM); System.out.println("Hypernym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Iterator itr = list.iterator(); itr.hasNext();) { ((Relationship) itr.next()).getNodeList().print(); } System.out.println("Common Parent Index: " + ((AsymmetricRelationship) list.get(0)).getCommonParentIndex()); System.out.println("Depth: " + ((Relationship) list.get(0)).getDepth()); }
private void demonstrateSymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException { // find all synonyms that <var>start</var> and <var>end</var> have in common RelationshipList list = RelationshipFinder.getInstance().findRelationships(start.getSense(1), end.getSense(1), PointerType.SIMILAR_TO); System.out.println("Synonym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Iterator itr = list.iterator(); itr.hasNext();) { ((Relationship) itr.next()).getNodeList().print(); } System.out.println("Depth: " + ((Relationship) list.get(0)).getDepth()); } }
private void demonstrateSymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException { // find all synonyms that <var>start</var> and <var>end</var> have in common RelationshipList list = RelationshipFinder.getInstance().findRelationships(start.getSense(1), end.getSense(1), PointerType.SIMILAR_TO); System.out.println("Synonym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Iterator itr = list.iterator(); itr.hasNext();) { ((Relationship) itr.next()).getNodeList().print(); } System.out.println("Depth: " + ((Relationship) list.get(0)).getDepth()); } }
private void demonstrateSymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException { // find all synonyms that <var>start</var> and <var>end</var> have in common RelationshipList list = RelationshipFinder.getInstance().findRelationships(start.getSense(1), end.getSense(1), PointerType.SIMILAR_TO); System.out.println("Synonym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Iterator itr = list.iterator(); itr.hasNext();) { ((Relationship) itr.next()).getNodeList().print(); } System.out.println("Depth: " + ((Relationship) list.get(0)).getDepth()); } }
private void demonstrateSymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException { // find all synonyms that <var>start</var> and <var>end</var> have in common RelationshipList list = RelationshipFinder.getInstance().findRelationships(start.getSense(1), end.getSense(1), PointerType.SIMILAR_TO); System.out.println("Synonym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Iterator itr = list.iterator(); itr.hasNext();) { ((Relationship) itr.next()).getNodeList().print(); } System.out.println("Depth: " + ((Relationship) list.get(0)).getDepth()); } }