@Override public List<SensedWord> getAllSensedWords() { List<IWord> objWords = realSynset.getWords(); List<SensedWord> sensedWords = new ArrayList<SensedWord>(objWords.size()); for ( IWord word : objWords) sensedWords.add(new JwiSensedWord(word, this.jwiDictionary)); return sensedWords; }
/** * @param iSynsets * @return */ private Set<String> getWordsOfSynsets(ISynset[] iSynsets) { Set<String> words = new HashSet<String>(); for (ISynset synset : iSynsets) for (IWord iWord : synset.getWords()) words.add(iWord.getLemma()); return words; }
public Set<String> getWords() throws WordNetException { Set<String> ret = new HashSet<String>(); for (IWord word : this.realSynset.getWords()) { ret.add(word.getLemma()); } return ret; }
/** * Get neighbors for a lexical relation type * @param antonym * @return */ protected Set<Synset> getLexicalNeighbors(Pointer pointer) { Set<Synset> synsets = new HashSet<Synset>(); for (IWord word : realSynset.getWords()) { synsets.addAll(jwiDictionary.getSetOfSynsetsOfWords( word.getRelatedWords(pointer) )); } return synsets; }
public ArrayList<String> getAllChildrenWords(ArrayList<ISynset> syns) { HashSet<ISynset> allsyns = new HashSet<ISynset>(); ArrayList<String> lemmas = new ArrayList<String>(); for(ISynset is: syns) { ArrayList<Triple<ISynset,Integer,ArrayList<IPointer>>> lis = getParents(is,0,new ArrayList<Triple<ISynset,Integer,ArrayList<IPointer>>>(), new ArrayList<IPointer>(), Pointer.HYPONYM); for(int i=0; i < lis.size(); i++) { allsyns.add(lis.get(i).getLeft()); } } for(ISynset is: allsyns) { List<IWord> lis = is.getWords(); for(IWord iw: lis) { if(!iw.getLemma().contains("_")) lemmas.add(iw.getLemma()); } } return lemmas; }
public ArrayList<String> getAllParentWords(ArrayList<ISynset> syns) { HashSet<ISynset> allsyns = new HashSet<ISynset>(); ArrayList<String> lemmas = new ArrayList<String>(); for(ISynset is: syns) { ArrayList<Triple<ISynset,Integer,ArrayList<IPointer>>> lis = getParents(is,0,new ArrayList<Triple<ISynset,Integer,ArrayList<IPointer>>>(), new ArrayList<IPointer>(), Pointer.HYPERNYM); for(int i=0; i < lis.size(); i++) { allsyns.add(lis.get(i).getLeft()); } } for(ISynset is: allsyns) { List<IWord> lis = is.getWords(); for(IWord iw: lis) { if(!iw.getLemma().contains("_")) lemmas.add(iw.getLemma()); } } return lemmas; }
public ArrayList<String> getAllChildrenWords(ArrayList<ISynset> syns) { HashSet<ISynset> allsyns = new HashSet<ISynset>(); ArrayList<String> lemmas = new ArrayList<String>(); for (ISynset is : syns) { ArrayList<Triple<ISynset, Integer, ArrayList<IPointer>>> lis = getParents(is, 0, new ArrayList<Triple<ISynset, Integer, ArrayList<IPointer>>>(), new ArrayList<IPointer>(), Pointer.HYPONYM); for (int i = 0; i < lis.size(); i++) { allsyns.add(lis.get(i).getLeft()); } } for (ISynset is : allsyns) { List<IWord> lis = is.getWords(); for (IWord iw : lis) { if (!iw.getLemma().contains("_")) lemmas.add(iw.getLemma()); } } return lemmas; }
public ArrayList<String> getAllParentWords(ArrayList<ISynset> syns) { HashSet<ISynset> allsyns = new HashSet<ISynset>(); ArrayList<String> lemmas = new ArrayList<String>(); for (ISynset is : syns) { ArrayList<Triple<ISynset, Integer, ArrayList<IPointer>>> lis = getParents(is, 0, new ArrayList<Triple<ISynset, Integer, ArrayList<IPointer>>>(), new ArrayList<IPointer>(), Pointer.HYPERNYM); for (int i = 0; i < lis.size(); i++) { allsyns.add(lis.get(i).getLeft()); } } for (ISynset is : allsyns) { List<IWord> lis = is.getWords(); for (IWord iw : lis) { if (!iw.getLemma().contains("_")) lemmas.add(iw.getLemma()); } } return lemmas; }
public List<WordAndUsage> getWordsAndUsages() throws WordNetException { List<IWord> words = this.realSynset.getWords(); List<WordAndUsage> wordsAndUsages = new ArrayList<WordAndUsage>(words.size()); for (IWord word : words) wordsAndUsages.add(new WordAndUsage(word.getLemma(), getUsageOf(word.getLemma()))); return wordsAndUsages; }
private void getHyperRecursive(HashSet<String> seen, IWord word, int hyperDepth, int dist) { if (dist > hyperDepth) return; List<ISynsetID> hypernyms = word.getSynset().getRelatedSynsets ( Pointer.HYPERNYM ); List <IWord> hw; for( ISynsetID sid : hypernyms ){ hw = mDict.getSynset(sid).getWords(); for(Iterator <IWord > i = hw.iterator (); i. hasNext () ;){ IWord relWord = i.next(); String wstr = printableName(relWord, mUseLexFileName); if (seen.contains(wstr)) continue; seen.add(wstr); getHyperRecursive(seen, relWord, hyperDepth,dist+1); } } }
public HashSet<String> getRelated(IIndexWord idxWord, IPointer type) { HashSet<String> seen = new HashSet<String>(); for (IWordID wordID: idxWord.getWordIDs()) { IWord word = mDict.getWord(wordID); List<ISynsetID> relList = word.getSynset().getRelatedSynsets(type); for( ISynsetID sid : relList){ List <IWord> hw = mDict.getSynset(sid).getWords(); for(Iterator <IWord > i = hw.iterator (); i. hasNext () ;){ IWord relWord = i.next(); seen.add(relWord.getLemma()); } } } return seen; }
public ArrayList<ISynset> getAllSynset(String word, POS pos) { // System.out.println(word+" "+pos); ArrayList<ISynset> syns = new ArrayList<ISynset>(); IIndexWord idxWord = null; try { idxWord = wrap.dict.getIndexWord(word, pos); // System.out.println(idxWord); } catch (IllegalArgumentException e) { } if (idxWord == null) return new ArrayList<ISynset>(); List<IWordID> senses = idxWord.getWordIDs(); for (IWordID iw : senses) { ISynset is = wrap.dict.getSynset(iw.getSynsetID()); List<IWord> words = is.getWords(); syns.add(is); } return syns; }
public ArrayList<ISynset> getAllSynset(String word, POS pos) { //System.out.println(word+" "+pos); ArrayList<ISynset> syns = new ArrayList<ISynset>(); IIndexWord idxWord = null; try { idxWord = wrap.dict.getIndexWord(word, pos); //System.out.println(idxWord); } catch(IllegalArgumentException e) { } if(idxWord==null) return new ArrayList<ISynset>(); List<IWordID> senses = idxWord.getWordIDs(); for(IWordID iw : senses) { ISynset is = wrap.dict.getSynset(iw.getSynsetID()); List<IWord> words = is.getWords(); syns.add(is); } return syns; }
public IWord getWord(IWordID id) { checkOpen(); ISynset synset = getSynset(id.getSynsetID()); if(synset == null) return null; // One or the other of the WordID number or lemma may not exist, // depending on whence the word id came, so we have to check // them before trying. if (id.getWordNumber() > 0) { return synset.getWords().get(id.getWordNumber() - 1); } else if (id.getLemma() != null) { for(IWord word : synset.getWords()) { if (word.getLemma().equalsIgnoreCase(id.getLemma())) return word; } return null; } else { throw new IllegalArgumentException("Not enough information in IWordID instance to retrieve word."); } }
/** * Ctor * @param synset * @param word * @throws WordNetException */ public JwiSensedWord(JwiSynset synset, String word) throws WordNetException { this.synset = synset; this.word = word; String wordToLookup = word.replace(' ', '_'); // mimic jwnl, which replaces underscores with spaces when looking up IWord iWord = null; boolean found = false; for (int i = 1; i <= synset.realSynset.getWords().size() && !found; i++) { iWord = synset.realSynset.getWord(i); found = iWord.getLemma().equalsIgnoreCase(wordToLookup); } if (!found) throw new WordNetException("\""+ word + "\" is not a memeber of the given synset " + synset); this.iWord = iWord; dictionary = synset.jwiDictionary; this.pos = JwiUtils.getWordNetPartOfSpeech(iWord.getPOS()); }
/** * Creates a new index word that replicates the specified index word. * The new index word replaces it's internal synset ids with synset ids * from the denoted synsets, thus removing redundant ids. * * @param old * the index word to be replicated * @return the new index word object * @throws NullPointerException * if the specified index word is <code>null</code> * @since JWI 2.2.0 */ protected IIndexWord makeIndexWord(IIndexWord old){ List<IWordID> oldIDs = old.getWordIDs(); IWordID[] newIDs = new IWordID[oldIDs.size()]; IWordID oldID; ISynset synset; for(int i = 0; i < oldIDs.size(); i++){ oldID = oldIDs.get(i); synset = synsets.get(oldID.getPOS()).get(oldID.getSynsetID()); for(IWord newWord : synset.getWords()){ if(!newWord.getID().equals(oldID)) continue; newIDs[i] = newWord.getID(); break; } if(newIDs[i] == null) throw new IllegalStateException(); } return new IndexWord(old.getID(), old.getTagSenseCount(), newIDs); }
for(IWord synsetMember : iSynset.getWords()) { synonyms.add(synsetMember.getLemma());
for(IWord synsetMember : iSynset.getWords()) { synonyms.add(synsetMember.getLemma());
/** * Caches the specified synset and its words. * * @param synset * the synset to be cached; may not be <code>null</code> * @throws NullPointerException * if the specified synset is <code>null</code> * @since JWI 2.2.0 */ protected void cacheSynset(ISynset synset){ IItemCache cache = getCache(); cache.cacheItem(synset); for(IWord word : synset.getWords()){ cache.cacheItem(word); cache.cacheWordByKey(word); } }
List<IWord> iWords = dict.getSynset(iSynsetId2).getWords(); for(IWord iWord2: iWords) { String lemma = iWord2.getLemma();