/** * This method is used when constructing the dictionary data object. * Constructs an map with an empty sub-map for every part of speech. * Subclasses may override to change map character * * @param <K> * the type of the keys for the sub-maps * @param <V> * the type of the values for the sub-maps * @return a map with an empty sub-map for every part of speech. * @since JWI 2.2.0 */ protected <K,V> Map<POS, Map<K,V>> makePOSMap(){ Map<POS, Map<K,V>> result = new HashMap<POS, Map<K,V>>(POS.values().length); for(POS pos : POS.values()) result.put(pos, this.<K,V>makeMap(4096, null)); return result; }
public ArrayList<ISynset> getAllSynset(String word) { ArrayList<ISynset> lis = new ArrayList<ISynset>(); for (POS p : POS.values()) { lis.addAll(getAllSynset(word, p)); // System.out.println(p+" "+Arrays.toString(lis.toArray())); } return lis; }
public ArrayList<ISynset> getAllSynset(String word) { ArrayList<ISynset> lis = new ArrayList<ISynset>(); for(POS p: POS.values()) { lis.addAll(getAllSynset(word, p)); //System.out.println(p+" "+Arrays.toString(lis.toArray())); } return lis; }
public Set<String> getWordNetStems(String word) { Set<String> stems = new HashSet<String>(); for (POS pos : POS.values()) stems.addAll(wnStemmer.findStems(word, pos)); return stems; } }
/** * Replaces redundant objects where possible * * @since JWI 2.2.0 */ public void compactObjects(){ for(POS pos : POS.values()){ for(Entry<ISynsetID, ISynset> entry : synsets.get(pos).entrySet()) entry.setValue(makeSynset(entry.getValue())); for(Entry<IIndexWordID, IIndexWord> entry : idxWords.get(pos).entrySet()) entry.setValue(makeIndexWord(entry.getValue())); } }
public IWord getSenseFromSenseKey(final String sensekey) { final String lemma = sensekey.split("%")[0]; final Set<IWord> senses = new HashSet<IWord>(); for (POS pos : POS.values()) senses.addAll(getSenses(lemma, pos)); for (IWord sense : senses) if (sense.getSenseKey().toString().equals(sensekey)) return sense; return null; }
public ArrayList<String> getStemsList(String word, POS pos) { //experimental change!!!!!!!!!!!!!!!!!!!!!!! List<String> stems = new ArrayList<String>(); if(pos!=null) { List<String> stems1 = wstem.findStems(word, pos); stems=fix(stems1, word.substring(0,1), word); } else { for (POS p : POS.values()) { try { List<String> stems1=wstem.findStems(word, p); stems.addAll(fix(stems1, word.substring(0,1), word)); } catch(Exception e) {} } } stems = new ArrayList<String>((new HashSet<String>(stems))); if(stems.size() == 0) { stems.add(word); return (ArrayList<String>) stems; } //System.out.println(Arrays.toString(stems.toArray(new String[0]))+" "+word); return (ArrayList<String>) stems; }
public ArrayList<String> getStemsList(String word, POS pos) { // experimental // change!!!!!!!!!!!!!!!!!!!!!!! List<String> stems = new ArrayList<String>(); if (pos != null) { List<String> stems1 = wstem.findStems(word, pos); stems = fix(stems1, word.substring(0, 1), word); } else { for (POS p : POS.values()) { try { List<String> stems1 = wstem.findStems(word, p); stems.addAll(fix(stems1, word.substring(0, 1), word)); } catch (Exception e) { } } } stems = new ArrayList<String>((new HashSet<String>(stems))); if (stems.size() == 0) { stems.add(word); return (ArrayList<String>) stems; } // System.out.println(Arrays.toString(stems.toArray(new String[0]))+" // "+word); return (ArrayList<String>) stems; }
@Override public boolean containsLexeme(String lexeme) throws LexicalSemanticResourceException { // iterate over all POS to check if there is an index word with given lexeme for (POS pos : POS.values()) { IIndexWord indexWord = dict.getIndexWord(lexeme, pos); if (indexWord != null) { if (isCaseSensitive) { if (indexWord.getLemma().equals(lexeme)) { return true; } } else { return true; } } /*if (idxWord != null) { String lemma = idxWord.getLemma(); if (lemma.equals(lexeme)) { return true; } }*/ } return false; }
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; }
for(POS p : POS.values()) result.addAll(findStems(word, p)); if(result.isEmpty())
public ArrayList<IWord> getIWords(String st, POS pos_) { List<String> stems = getStemsList(st, pos_); ArrayList<IWord> iwds = new ArrayList<IWord>(); for(String s: stems){ //System.out.println(s); for (POS pos : POS.values()) { if(pos_!=null && !pos.equals(pos_)) continue; IIndexWord idxWord = dict.getIndexWord(s, pos); //System.out.println(idxWord); if(idxWord==null) continue; List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning for(IWordID iw : senses) { //System.out.println(iw); iwds.add(dict.getWord(iw)); } } } return iwds; }
public ArrayList<IWord> getIWords(String st, POS pos_) { List<String> stems = getStemsList(st, pos_); ArrayList<IWord> iwds = new ArrayList<IWord>(); for (String s : stems) { // System.out.println(s); for (POS pos : POS.values()) { if (pos_ != null && !pos.equals(pos_)) continue; IIndexWord idxWord = dict.getIndexWord(s, pos); // System.out.println(idxWord); if (idxWord == null) continue; List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning for (IWordID iw : senses) { // System.out.println(iw); iwds.add(dict.getWord(iw)); } } } return iwds; }
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); } } } }
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)); } } } }
for(String s: stems){ for (POS pos : POS.values()) { if(pos_ !=null && !pos.equals(pos_)) continue;
for (String s : stems) { for (POS pos : POS.values()) { if (pos_ != null && !pos.equals(pos_)) continue;
double min2 = 100; double sum = 100; for (POS pos : POS.values()) { min1 = 100; min2 = 100;