/** * Returns the number of this word (1-based) or 0 if not found. * NB Word numbers are assigned to the word fields in a synset, from left to right, beginning with 1. * * @return the number of this word */ @Override public int getIndex() { int result = 0; if (null != synset) { result = synset.getWords().indexOf(this) + 1; } return result; }
protected static void initVerbFrameFlags(final Synset synset, final BitSet vFrames, final int frameNumber, final int wordIndex) { if (wordIndex > 0) { ((Verb) synset.getWords().get(wordIndex - 1)).getVerbFrameFlags().set(frameNumber); } else { for (Word w : synset.getWords()) { ((Verb) w).getVerbFrameFlags().set(frameNumber); } vFrames.set(frameNumber); } }
@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(); }
protected static void initVerbFrameFlags(final Synset synset, final BitSet vFrames, final int frameNumber, final int wordIndex) { if (wordIndex > 0) { ((Verb) synset.getWords().get(wordIndex - 1)).getVerbFrameFlags().set(frameNumber); } else { for (Word w : synset.getWords()) { ((Verb) w).getVerbFrameFlags().set(frameNumber); } vFrames.set(frameNumber); } }
@Override public List<SensedWord> getAllSensedWords() throws WordNetException { List<Word> objWords = realSynset.getWords(); List<SensedWord> sensedWords = new ArrayList<SensedWord>(objWords.size()); for ( Word word : objWords) sensedWords.add( new ExtJwnlSensedWord(word, this.extJwnlDictionary)); return sensedWords; }
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; }
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 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 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 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; }
public CachedSense(String senseId) throws SenseInventoryException { super(senseId); synset = stringToSynset.transform(id); pos = wordNetPosToSiPos.transform(synset.getPOS()); useCount = 0; for (Word word : synset.getWords()) { useCount += word.getUseCount(); } }
private void addWord(Synset synset, String lemma) { if (null != synset.getDictionary() && synset.getDictionary().isEditable()) { if (!synset.containsWord(lemma)) { synset.getWords().add(new Word(synset.getDictionary(), synset, lemma)); } } }
private void addWord(Synset synset, String lemma) { if (null != synset.getDictionary() && synset.getDictionary().isEditable()) { if (!synset.containsWord(lemma)) { synset.getWords().add(new Word(synset.getDictionary(), synset, lemma)); } } }
private Synset parseAndCacheSynset(POS pos, PointedCharSequence line) throws JWNLException { Synset result = null; if (null != line) { result = factory.createSynset(pos, line); for (Word w : result.getWords()) { w.setUseCount(fileManager.getUseCount(w.getSenseKeyWithAdjClass())); } cacheSynset(result); } return result; } }
private Synset parseAndCacheSynset(POS pos, PointedCharSequence line) throws JWNLException { Synset result = null; if (null != line) { result = factory.createSynset(pos, line); for (Word w : result.getWords()) { w.setUseCount(fileManager.getUseCount(w.getSenseKeyWithAdjClass())); } cacheSynset(result); } return result; } }