public Set<Synset> getCoordinateTerms() throws WordNetException { try { return getSetOfSynsets(PointerUtils.getInstance().getCoordinateTerms(this.realSynset)); } catch (JWNLException e) { throw new WordNetException("See nested", e); } }
private void demonstrateTreeOperation(IndexWord word) throws JWNLException { // Get all the hyponyms (children) of the first sense of <var>word</var> PointerTargetTree hyponyms = PointerUtils.getInstance().getHyponymTree(word.getSense(1)); System.out.println("Hyponyms of \"" + word.getLemma() + "\":"); hyponyms.print(); }
public Set<Synset> getHolonyms() throws WordNetException { try { return getSetOfSynsets(PointerUtils.getInstance().getHolonyms(this.realSynset)); } catch (JWNLException e) { throw new WordNetException("See nested", e); } }
private void demonstrateListOperation(IndexWord word) throws JWNLException { // Get all of the hypernyms (parents) of the first sense of <var>word</var> PointerTargetNodeList hypernyms = PointerUtils.getInstance().getDirectHypernyms(word.getSense(1)); System.out.println("Direct hypernyms of \"" + word.getLemma() + "\":"); hypernyms.print(); }
private void demonstrateTreeOperation(IndexWord word) throws JWNLException { // Get all the hyponyms (children) of the first sense of <var>word</var> PointerTargetTree hyponyms = PointerUtils.getInstance().getHyponymTree(word.getSense(1)); System.out.println("Hyponyms of \"" + word.getLemma() + "\":"); hyponyms.print(); }
private void demonstrateListOperation(IndexWord word) throws JWNLException { // Get all of the hypernyms (parents) of the first sense of <var>word</var> PointerTargetNodeList hypernyms = PointerUtils.getInstance().getDirectHypernyms(word.getSense(1)); System.out.println("Direct hypernyms of \"" + word.getLemma() + "\":"); hypernyms.print(); }
private void demonstrateTreeOperation(IndexWord word) throws JWNLException { // Get all the hyponyms (children) of the first sense of <var>word</var> PointerTargetTree hyponyms = PointerUtils.getInstance().getHyponymTree(word.getSense(1)); System.out.println("Hyponyms of \"" + word.getLemma() + "\":"); hyponyms.print(); }
private void demonstrateListOperation(IndexWord word) throws JWNLException { // Get all of the hypernyms (parents) of the first sense of <var>word</var> PointerTargetNodeList hypernyms = PointerUtils.getInstance().getDirectHypernyms(word.getSense(1)); System.out.println("Direct hypernyms of \"" + word.getLemma() + "\":"); hypernyms.print(); }
private void demonstrateListOperation(IndexWord word) throws JWNLException { // Get all of the hypernyms (parents) of the first sense of <var>word</var> PointerTargetNodeList hypernyms = PointerUtils.getInstance().getDirectHypernyms(word.getSense(1)); System.out.println("Direct hypernyms of \"" + word.getLemma() + "\":"); hypernyms.print(); }
private void demonstrateTreeOperation(IndexWord word) throws JWNLException { // Get all the hyponyms (children) of the first sense of <var>word</var> PointerTargetTree hyponyms = PointerUtils.getInstance().getHyponymTree(word.getSense(1)); System.out.println("Hyponyms of \"" + word.getLemma() + "\":"); hyponyms.print(); }
public Set<Synset> getMeronyms() throws WordNetException { try { return getSetOfSynsets(PointerUtils.getInstance().getMeronyms(this.realSynset)); } catch (JWNLException e) { throw new WordNetException("See nested", e); } }
private WordNetAPI(InputStream propsFile) throws Exception { info("Initialize WordNet...: "); if (propsFile == null) throw new RuntimeException("Missing required property 'WN_PROP'"); try { JWNL.initialize(propsFile); wDict = Dictionary.getInstance(); pUtils = PointerUtils.getInstance(); morphProcessor = wDict.getMorphologicalProcessor(); } catch (Exception e) { throw new RuntimeException("Initialization failed", e); } info("Done initializing WordNet..."); }
PointerTargetNodeList relatedListHyponyms = null; try { relatedListHypernyms = PointerUtils.getInstance().getDirectHypernyms(sense); relatedListHyponyms = PointerUtils.getInstance().getDirectHyponyms(sense);
public void getHyponymsRecursive(List<String> lemmas, Synset sense, int depthToGo) { for (Word w : sense.getWords()) { lemmas.add(w.getLemma()); } if (depthToGo == 0) { return; } try { PointerTargetNodeList directHyponyms = PointerUtils.getInstance().getDirectHyponyms(sense); for (Object directHyponym : directHyponyms) { getHyponymsRecursive(lemmas, ((PointerTargetNode) directHyponym).getSynset(), depthToGo - 1); } } catch (JWNLException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
/** 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 void getHyponymsScoredRecursive(List<LemmaScorePair> lemmas, Synset sense, int depthToGo, double score) { for (Word w : sense.getWords()) { lemmas.add(new LemmaScorePair(w.getLemma(), score)); } if (depthToGo == 0) { return; } try { PointerTargetNodeList directHyponyms = PointerUtils.getInstance().getDirectHyponyms(sense); for (Object directHyponym : directHyponyms) { getHyponymsScoredRecursive(lemmas, ((PointerTargetNode) directHyponym).getSynset(), depthToGo - 1, score * HYPONYM_FACTOR); } } catch (JWNLException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
result.add(w.getLemma()); PointerTargetNodeList target = PointerUtils.getInstance().getDirectHypernyms(sense); while (target != null && !target.isEmpty()) { for (Object aTarget : target) { target = PointerUtils.getInstance().getDirectHyponyms(((PointerTargetNode) target.get(0)).getSynset()); System.out.println(target);
/** * 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; }
public Set<Synset> getRelatedSynsets(WordNetRelation relation, int chainingLength) throws WordNetException { if (chainingLength < 1) throw new WordNetException("chaining length must be positive. I got " + chainingLength); if (WordNetRelation.STRICT_2ND_DEGREE_COUSIN.equals(relation)) throw new WordNetMethodNotSupportedException("Extracting cousin relations is currently not supported by JwnlDictionary. Use JwiDictionary instead"); PointerType pointerType = JwnlUtils.wordNetRelationToPointerType(relation); if (pointerType == null) // some relations (inc. SYNONYM) have no neighbors, cos they have no matching JWNL relation // other relations just don't exist in ext JWNL return new HashSet<Synset>(); else { if (!relation.isTransitive()) chainingLength = 1; // most relations make no sense when chained try { return getSetOfSynsets(PointerUtils.getInstance().makePointerTargetTreeList(realSynset, pointerType, chainingLength)); } catch (JWNLException e) { throw new WordNetException("see nested" , e); } } }