/** 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()); }
/** A symmetric relationship is one whose type is symmetric (i.e. is it's own inverse). */ private RelationshipList findSymmetricRelationships( final Synset sourceSynset, final Synset targetSynset, PointerType type, int depth) throws JWNLException { PointerTargetTree tree = new PointerTargetTree( sourceSynset, PointerUtils.getInstance().makePointerTargetTreeList(sourceSynset, type, null, depth, false)); PointerTargetTreeNodeList.Operation opr = new PointerTargetTreeNodeList.Operation() { public Object execute(PointerTargetTreeNode testNode) { if (targetSynset.equals(testNode.getPointerTarget())) { return testNode; } return null; } }; List l = tree.getAllMatches(opr); RelationshipList list = new RelationshipList(); for (int i = 0; i < l.size(); i++) { PointerTargetNodeList nodes = findSymmetricRelationship((PointerTargetTreeNode)l.get(i), type); list.add(new SymmetricRelationship(type, nodes, sourceSynset, targetSynset)); } return list; }
public synchronized boolean add(Object o) { int curSize = size(); boolean success = super.add(o); if (success) { Relationship r = (Relationship)o; if (r.getDepth() < _shallowestIndex) { _shallowestIndex = curSize; } if (r.getDepth() > _deepestIndex) { _deepestIndex = curSize; } } return success; }
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()); }
/** * 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, int depth) throws JWNLException { // We run the reversal function on the trees to get linear (non-branching) // paths from the source word to its deepest ancestor (i.e. if there are // multiple relations from a single word anywhere in the path, the reversal // function will break them down into multiple, linear paths). PointerTargetNodeList[] sourceRelations = new PointerTargetTree( sourceSynset, PointerUtils.getInstance().makePointerTargetTreeList(sourceSynset, type, depth)).reverse(); PointerTargetNodeList[] targetRelations = new PointerTargetTree( targetSynset, PointerUtils.getInstance().makePointerTargetTreeList(targetSynset, type, depth)).reverse(); RelationshipList relationships = new RelationshipList(); // Do an exhaustive search for relationships for (int i = 0; i < sourceRelations.length; i++) { for (int j = 0; j < targetRelations.length; j++) { Relationship relationship = findAsymmetricRelationship( sourceRelations[i], targetRelations[j], type, sourceSynset, targetSynset); if (relationship != null) { relationships.add(relationship); } } } return relationships; }
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; }
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()); } }