public POS getPOS() { return id.getSynsetID().getPOS(); }
@Override public String toString() { if (id.getWordNumber() == 0) { return "W-" + id.getSynsetID().toString().substring(4) + "-?-" + id.getLemma(); } else { return "W-" + id.getSynsetID().toString().substring(4) + "-" + id.getWordNumber() + "-" + id.getLemma(); } }
public IWord getWord(IWordID id) { if(data != null){ ISynset synset = data.synsets.get(id.getPOS()).get(id.getSynsetID()); return (synset == null) ? null : synset.getWord(id.getWordNumber()); } else { return backing.getWord(id); } }
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 static Set<Synset> toSynset(Dictionary dict, String lexeme, boolean isCaseSensitive) throws LexicalSemanticResourceException { Set<IIndexWord> indexWords = new HashSet<IIndexWord>(); Set<Synset> resultsSynsets = new HashSet<Synset>(); for (POS pos : POS.values()) { IIndexWord indexWord = dict.getIndexWord(lexeme, pos); if (indexWord != null) { if (!isCaseSensitive) { indexWords.add(indexWord); } else { if(indexWord.getLemma().equals(lexeme)) { indexWords.add(indexWord); } } } } for (IIndexWord indexWord : indexWords) { if (indexWord != null) { List<IWordID> iwordIDs = indexWord.getWordIDs(); for (IWordID iwordID : iwordIDs) { resultsSynsets.add((Synset) dict.getSynset(iwordID.getSynsetID())); } } } return resultsSynsets; }
public static Set<Synset> toSynset(Dictionary dict, String lexeme, PoS pos, boolean isCaseSensitive) { Set<IndexWord> indexWords = new HashSet<IndexWord>(); for (POS wnPOS : mapPos(pos)) { IndexWord indexWord = (IndexWord)dict.getIndexWord(lexeme, wnPOS); if (indexWord != null) { if(!isCaseSensitive) { indexWords.add(indexWord); } else { if (indexWord.getLemma().equals(lexeme)) { indexWords.add(indexWord); } } } } Set<Synset> resultsSynsets = new HashSet<Synset>(); for (IndexWord indexWord : indexWords) { if (indexWord != null) { List<IWordID> iwordIDs = indexWord.getWordIDs(); for (IWordID iwordID : iwordIDs) { resultsSynsets.add((Synset) dict.getSynset(iwordID.getSynsetID())); } } } return resultsSynsets; }
/** * 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); }
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."); } }
newList = new ArrayList<IWordID>(entry.getValue().size()); for(IWordID otherID : entry.getValue()){ otherSynset = synsets.get(otherID.getPOS()).get(otherID.getSynsetID()); newList.add(otherSynset.getWord(otherID.getWordNumber()).getID());
public void getAllSemanticRelations(String lemma) { //for each stem, for each sense in stemn\,print lemma, sensem, probability, sr and lr List<String> stems = wstem.findStems(lemma, null); for(String s: stems){ for (POS pos : POS.values()) { IIndexWord idxWord = dict.getIndexWord(lemma, pos) ; if(idxWord==null) continue; List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning for(IWordID iw : senses) { ISynset is = dict.getSynset(iw.getSynsetID()); System.out.println(is.getGloss()); getAllSemanticRelations(is); } } } }
public void getAllSemanticRelations(String lemma) { // for each stem, for each sense in stemn\,print lemma, sensem, // probability, sr and lr List<String> stems = wstem.findStems(lemma, null); for (String s : stems) { for (POS pos : POS.values()) { IIndexWord idxWord = dict.getIndexWord(lemma, pos); if (idxWord == null) continue; List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning for (IWordID iw : senses) { ISynset is = dict.getSynset(iw.getSynsetID()); System.out.println(is.getGloss()); getAllSemanticRelations(is); } } } }
ISynset is = dict.getSynset(iw.getSynsetID()); List<IWord> words = is.getWords(); if(isAcceptable(words, word) || flag) {
ISynset is = dict.getSynset(iw.getSynsetID()); List<IWord> words = is.getWords(); if (isAcceptable(words, word) || flag) {
public void getAllLexicalRelations(String lemma) { //for each stem, for each sense in stemn\,print lemma, sensem, probability, sr and lr List<String> stems = wstem.findStems(lemma, null); for(String s: stems){ for (POS pos : POS.values()) { IIndexWord idxWord = dict.getIndexWord(lemma, pos) ; if(idxWord==null) continue; List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning for(IWordID iw : senses) { ISynset is = dict.getSynset(iw.getSynsetID()); System.out.println(is.getGloss()); getAllLexicalRelations(dict.getWord(iw)); } } } }
public void getAllLexicalRelations(String lemma) { // for each stem, for each sense in stemn\,print lemma, sensem, // probability, sr and lr List<String> stems = wstem.findStems(lemma, null); for (String s : stems) { for (POS pos : POS.values()) { IIndexWord idxWord = dict.getIndexWord(lemma, pos); if (idxWord == null) continue; List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning for (IWordID iw : senses) { ISynset is = dict.getSynset(iw.getSynsetID()); System.out.println(is.getGloss()); getAllLexicalRelations(dict.getWord(iw)); } } } }