@Override public Set<String> getSynonyms() { if (synonyms != null) { return synonyms; } synonyms = new HashSet<String>(); for (Word word : synset.getWords()) { synonyms.add(word.getLemma().replace('_', ' ')); } return synonyms; }
/** * This method consumes a targeted WordNet-synset, and returns the semantic label.<br> * Semantic label is the lemma of the synset's first lexeme. * @param targetSynset WordNet's synset from which the semantic label should be extracted * @return the the lemma of the targetSynset's first lexeme */ private String getSemanticLabel(net.sf.extjwnl.data.Synset targetSynset) { return targetSynset.getWords().get(0).getLemma(); }
public Set<String> getWords() throws WordNetException { if (words == null) { words = new LinkedHashSet<String>(); for (Word word : this.realSynset.getWords()) { String lemma = word.getLemma(); lemma = lemma.replaceAll("_", " "); // clean words.add(lemma); } } return new LinkedHashSet<String>(words); // return a copy }
@Override public Set<String> getSynonyms() { if (synonyms != null) { return synonyms; } synonyms = new HashSet<String>(synset.getWords().size()); for (Word w : synset.getWords()) { synonyms.add(w.getLemma()); } return synonyms; }
public static Map<String, String> getSynsetLexemes(Synset synset) { Map<String, String> result = new HashMap<String, String>(); long sense = synset.getOffset(); List<Word> words = synset.getWords(); for (Word word : words) { String lexeme = word.getLemma(); // remove some suffixes that might be added to the synset representation by JWNL lexeme = cleanLexeme(lexeme); result.put(lexeme, new Long(sense).toString()); } return result; }
public int hashCode() { return getSynset().hashCode() ^ getLemma().hashCode(); }
private void removeWordsFromSynset(Synset synset, String lemma) { if (null != dictionary && dictionary.isEditable()) { for (Word word : synset.getWords()) { if (word.getLemma().equalsIgnoreCase(lemma)) { synset.getWords().remove(word); break; } } } }
private void removeWordsFromSynset(Synset synset, String lemma) { if (null != dictionary && dictionary.isEditable()) { for (Word word : synset.getWords()) { if (word.getLemma().equalsIgnoreCase(lemma)) { synset.getWords().remove(word); break; } } } }
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 static int getUseCount(Synset synset, String lemma) { for (Word w : synset.getWords()) { if (w.getLemma().equalsIgnoreCase(lemma)) { if (0 < w.getUseCount()) { return w.getUseCount(); } } } return 0; }
private static int getUseCount(Synset synset, String lemma) { for (Word w : synset.getWords()) { if (w.getLemma().equalsIgnoreCase(lemma)) { if (0 < w.getUseCount()) { return w.getUseCount(); } } } return 0; }
public String toString() { StringBuilder words = new StringBuilder(); for (int i = 0; i < this.words.size(); ++i) { if (i > 0) { words.append(", "); } words.append(this.words.get(i).getLemma()); } if (getGloss() != null) { words.append(" -- (").append(getGloss()).append(")"); } return ResourceBundleSet.insertParams("[Synset: [Offset: {0}] {1} Words: {2}]", new Object[]{getOffset(), getPOS(), words.toString()}); }
public String toString() { StringBuilder words = new StringBuilder(); for (int i = 0; i < this.words.size(); ++i) { if (i > 0) { words.append(", "); } words.append(this.words.get(i).getLemma()); } if (getGloss() != null) { words.append(" -- (").append(getGloss()).append(")"); } return ResourceBundleSet.insertParams("[Synset: [Offset: {0}] {1} Words: {2}]", new Object[]{getOffset(), getPOS(), words.toString()}); }
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 String toString() { return ResourceBundleSet.insertParams("[Word: {0} [Lemma: {1}] {2} [Index: {3}]]", new Object[]{getPOS(), getLemma(), getSynset(), getIndex()}); }
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; }