protected Set<Synset> indexWordToSet(IndexWord indexWord) throws JWNLException { Set<Synset> ret = new LinkedHashSet<Synset>(); if (indexWord!=null) { for (net.sf.extjwnl.data.Synset jwnlRealSynset : indexWord.getSenses()) { ret.add(new ExtJwnlSynset(this, jwnlRealSynset)); } } return ret; }
/** * Finds out how many senses the word with part-of-speech <var>pos</var> has. * * @param pos POS * @return number of senses the word with part-of-speech <var>pos</var> has */ public int getSenseCount(POS pos) { int result = 0; IndexWord indexWord = getIndexWord(pos); if (null != indexWord) { result = indexWord.getSenses().size(); } return result; }
private static boolean hasUseCount(final IndexWord iw) { for (final Synset synset : iw.getSenses()) { for (final Word word : synset.getWords()) { if (0 < word.getUseCount()) { return true; } } } return false; }
private static boolean hasPointer(final IndexWord iw, final PointerType pointerType) { for (final Synset synset : iw.getSenses()) { for (final Pointer pointer : synset.getPointers()) { if (pointerType == pointer.getType()) { return true; } } } return false; }
private static boolean hasPointer(final IndexWord iw, final PointerType pointerType) { for (final Synset synset : iw.getSenses()) { for (final Pointer pointer : synset.getPointers()) { if (pointerType == pointer.getType()) { return true; } } } return false; }
private void demonstrateListOperation(IndexWord word) throws JWNLException { // Get all of the hypernyms (parents) of the first sense of <var>word</var> PointerTargetNodeList hypernyms = PointerUtils.getDirectHypernyms(word.getSenses().get(0)); 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.getHyponymTree(word.getSenses().get(0)); System.out.println("Hyponyms of \"" + word.getLemma() + "\":"); hyponyms.print(); }
private void demonstrateTreeOperation(IndexWord word) throws JWNLException { // Get all the hyponyms (children) of the first sense of <var>word</var> PointerTargetTree hyponyms = PointerUtils.getHyponymTree(word.getSenses().get(0)); 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.getDirectHypernyms(word.getSenses().get(0)); System.out.println("Direct hypernyms of \"" + word.getLemma() + "\":"); hypernyms.print(); }
private static boolean hasUseCount(final IndexWord iw) { for (final Synset synset : iw.getSenses()) { for (final Word word : synset.getWords()) { if (0 < word.getUseCount()) { return true; } } } return false; }
private void demonstrateSymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException, CloneNotSupportedException { // find all synonyms that <var>start</var> and <var>end</var> have in common RelationshipList list = RelationshipFinder.findRelationships(start.getSenses().get(0), end.getSenses().get(0), PointerType.SIMILAR_TO); System.out.println("Synonym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Object aList : list) { ((Relationship) aList).getNodeList().print(); } System.out.println("Depth: " + list.get(0).getDepth()); } }
public static Set<String> getSynonyms(String word) throws JWNLException { IndexWord[] allWords = getWordArray(word); if (allWords.length == 1) { Set<String> retData = new HashSet<>(); for (Synset synset : allWords[0].getSenses()) { for (Word wordObj : synset.getWords()) { retData.add(wordObj.getLemma()); } } return retData; } return null; }
private void demonstrateSymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException, CloneNotSupportedException { // find all synonyms that <var>start</var> and <var>end</var> have in common RelationshipList list = RelationshipFinder.findRelationships(start.getSenses().get(0), end.getSenses().get(0), PointerType.SIMILAR_TO); System.out.println("Synonym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Object aList : list) { ((Relationship) aList).getNodeList().print(); } System.out.println("Depth: " + list.get(0).getDepth()); } }
private void demonstrateAsymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException, CloneNotSupportedException { // Try to find a relationship between the first sense of <var>start</var> and the first sense of <var>end</var> RelationshipList list = RelationshipFinder.findRelationships(start.getSenses().get(0), end.getSenses().get(0), PointerType.HYPERNYM); System.out.println("Hypernym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Object aList : list) { ((Relationship) aList).getNodeList().print(); } System.out.println("Common Parent Index: " + ((AsymmetricRelationship) list.get(0)).getCommonParentIndex()); System.out.println("Depth: " + list.get(0).getDepth()); }
private void demonstrateAsymmetricRelationshipOperation(IndexWord start, IndexWord end) throws JWNLException, CloneNotSupportedException { // Try to find a relationship between the first sense of <var>start</var> and the first sense of <var>end</var> RelationshipList list = RelationshipFinder.findRelationships(start.getSenses().get(0), end.getSenses().get(0), PointerType.HYPERNYM); System.out.println("Hypernym relationship between \"" + start.getLemma() + "\" and \"" + end.getLemma() + "\":"); for (Object aList : list) { ((Relationship) aList).getNodeList().print(); } System.out.println("Common Parent Index: " + ((AsymmetricRelationship) list.get(0)).getCommonParentIndex()); System.out.println("Depth: " + list.get(0).getDepth()); }
private static int getSenseNo(final Word word) throws JWNLException { final IndexWord iw = word.getDictionary().getIndexWord(word.getPOS(), word.getLemma()); for (int i = 0; i < iw.getSenses().size(); i++) { if (iw.getSenses().get(i).getOffset() == word.getSynset().getOffset()) { return i; } } return -1; }
private static int getSenseNo(final Word word) throws JWNLException { final IndexWord iw = word.getDictionary().getIndexWord(word.getPOS(), word.getLemma()); for (int i = 0; i < iw.getSenses().size(); i++) { if (iw.getSenses().get(i).getOffset() == word.getSynset().getOffset()) { return i; } } return -1; }
private void removeThisSynsetFromIndexWords(Word word) { if (null != dictionary && dictionary.isEditable()) { try { IndexWord indexWord = dictionary.getIndexWord(getPOS(), word.getLemma()); if (null != indexWord) { indexWord.getSenses().remove(Synset.this); } } catch (JWNLException e) { throw new JWNLRuntimeException(e); } } }
private void removeThisSynsetFromIndexWords(Word word) { if (null != dictionary && dictionary.isEditable()) { try { IndexWord indexWord = dictionary.getIndexWord(getPOS(), word.getLemma()); if (null != indexWord) { indexWord.getSenses().remove(Synset.this); } } catch (JWNLException e) { throw new JWNLRuntimeException(e); } } }
public List<Synset> getSynsets() { try { return Dictionary.getDefaultResourceInstance() .lookupIndexWord(WSDHelper.getPOS(this.getTargetTag()), this.getTargetWord()) .getSenses(); } catch (JWNLException e) { e.printStackTrace(); } return null; }