public int getNumSenses(String lemma, String pos) { try { IndexWord iw = dict.getIndexWord(POS.NOUN,lemma); if (iw == null){ return 0; } return iw.getSenseCount(); } catch (JWNLException e) { return 0; } }
public int getNumSenses(String lemma, String pos) { try { IndexWord iw = dict.getIndexWord(POS.NOUN,lemma); if (iw == null) { return 0; } return iw.getSenseCount(); } catch (JWNLException e) { return 0; } }
public String getSenseKey(String lemma, String pos,int sense) { try { IndexWord iw = dict.getIndexWord(POS.NOUN,lemma); if (iw == null) { return null; } return String.valueOf(iw.getSynsetOffsets()[sense]); } catch (JWNLException e) { e.printStackTrace(); return null; } }
public String getSenseKey(String lemma, String pos,int sense) { try { IndexWord iw = dict.getIndexWord(POS.NOUN,lemma); if (iw == null) { return null; } return String.valueOf(iw.getSynsetOffsets()[sense]); } catch (JWNLException e) { e.printStackTrace(); return null; } }
public boolean execute(POS pos, String lemma, BaseFormSet baseForms) throws JWNLException { if (Dictionary.getInstance().getIndexWord(pos, lemma) != null) { baseForms.add(lemma); return true; } return false; } }
public List<String> getHyponyms(POS pos, String s) { ArrayList<String> result = new ArrayList<>(); try { IndexWord word = dict.getIndexWord(pos, s); if (word == null) { System.err.println("Unable to find index word for " + s); return result; } Synset sense = word.getSense(1); getHyponymsRecursive(result, sense, 3); } catch (JWNLException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return result; }
public List<LemmaScorePair> getHyponymsScored(POS pos, String s) { ArrayList<LemmaScorePair> result = new ArrayList<>(); try { IndexWord word = dict.getIndexWord(pos, s); if (word == null) { System.err.println("Unable to find index word for " + s); return result; } Synset sense = word.getSense(1); getHyponymsScoredRecursive(result, sense, 3, SYNONYM_FACTOR); } catch (JWNLException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return result; }
public String[] getParentSenseKeys(String lemma, String pos, int sense) { //System.err.println("JWNLDictionary.getParentSenseKeys: lemma="+lemma); try { IndexWord iw = dict.getIndexWord(POS.NOUN,lemma); if (iw != null) { Synset synset = iw.getSense(sense+1); List<String> parents = new ArrayList<String>(); getParents(synset,parents); return parents.toArray(new String[parents.size()]); } else { return empty; } } catch (JWNLException e) { e.printStackTrace(); return null; } }
public String[] getParentSenseKeys(String lemma, String pos, int sense) { //System.err.println("JWNLDictionary.getParentSenseKeys: lemma="+lemma); try { IndexWord iw = dict.getIndexWord(POS.NOUN,lemma); if (iw != null) { Synset synset = iw.getSense(sense + 1); List<String> parents = new ArrayList<>(); getParents(synset,parents); return parents.toArray(new String[parents.size()]); } else { return empty; } } catch (JWNLException e) { e.printStackTrace(); return null; } }
public List<String> getAttributes(String s) { List<String> result = new ArrayList<>(); try { IndexWord iw = dict.getIndexWord(POS.ADJECTIVE, s); if (iw != null) { Synset[] synsets = iw.getSenses(); Word[] words = synsets[0].getWords(); for (Word w : words) { String c = w.getLemma(); if (!c.equals(s) && !c.contains(" ") && result.size() < 4) { result.add(c); } } } } catch (JWNLException e) { e.printStackTrace(); } return result; }
public List<String> getBestSynonyms(POS pos, String s) { List<String> synonyms = new ArrayList<>(); try { IndexWord iw = dict.getIndexWord(pos, s);//dict.getMorphologicalProcessor().lookupBaseForm(pos, s) // IndexWord iw = dict.getMorphologicalProcessor().lookupBaseForm(pos, s); if (iw != null) { Synset[] synsets = iw.getSenses(); Word[] words = synsets[0].getWords(); for (Word w : words) { String c = w.getLemma(); if (!c.equals(s) && !c.contains(" ") && synonyms.size() < 4) { synonyms.add(c); } } } } catch (JWNLException e) { e.printStackTrace(); } return synonyms; }
public List<String> getAllSynonyms(POS pos, String s) { List<String> synonyms = new ArrayList<>(); try { IndexWord iw = dict.getIndexWord(pos, s); if (iw != null) { Synset[] synsets = iw.getSenses(); for (Synset synset : synsets) { for (Word w : synset.getWords()) { String lemma = w.getLemma(); if (!lemma.equals(s) && !lemma.contains(" ")) { synonyms.add(lemma); } } } } } catch (JWNLException e) { e.printStackTrace(); } return synonyms; }
public List<String> getSisterTerms(POS pos, String s) { List<String> sisterTerms = new ArrayList<>(); try { IndexWord iw = dict.getIndexWord(pos, s);//dict.getMorphologicalProcessor().lookupBaseForm(pos, s) // IndexWord iw = dict.getMorphologicalProcessor().lookupBaseForm(pos, s); if (iw != null) { Synset[] synsets = iw.getSenses(); //System.out.println(synsets[0]); PointerTarget[] pointerArr = synsets[0].getTargets(); } } catch (JWNLException e) { e.printStackTrace(); } return sisterTerms; }
/** * Returns a list of lemmas for the most frequent synset of the given word. * @param word word to get synonyms for * @param pos POS of the word to look up * @return list of lemmas of the most frequent synset */ public List<String> getWordsForFirstSynset(POS pos, String word) { List<String> result = new ArrayList<>(); IndexWord indexWord = null; Synset sense = null; try { indexWord = dict.getIndexWord(pos, word); sense = indexWord.getSense(1); for (Word w : sense.getWords()) { result.add(w.getLemma()); } } catch (JWNLException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return result; }
public Examples() throws JWNLException { ACCOMPLISH = Dictionary.getInstance().getIndexWord(POS.VERB, "accomplish"); DOG = Dictionary.getInstance().getIndexWord(POS.NOUN, "dog"); CAT = Dictionary.getInstance().lookupIndexWord(POS.NOUN, "cat"); FUNNY = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "funny"); DROLL = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "droll"); }
public Examples() throws JWNLException { ACCOMPLISH = Dictionary.getInstance().getIndexWord(POS.VERB, "accomplish"); DOG = Dictionary.getInstance().getIndexWord(POS.NOUN, "dog"); CAT = Dictionary.getInstance().lookupIndexWord(POS.NOUN, "cat"); FUNNY = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "funny"); DROLL = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "droll"); }
public Examples() throws JWNLException { ACCOMPLISH = Dictionary.getInstance().getIndexWord(POS.VERB, "accomplish"); DOG = Dictionary.getInstance().getIndexWord(POS.NOUN, "dog"); CAT = Dictionary.getInstance().lookupIndexWord(POS.NOUN, "cat"); FUNNY = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "funny"); DROLL = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "droll"); }
public Examples() throws JWNLException { ACCOMPLISH = Dictionary.getInstance().getIndexWord(POS.VERB, "accomplish"); DOG = Dictionary.getInstance().getIndexWord(POS.NOUN, "dog"); CAT = Dictionary.getInstance().lookupIndexWord(POS.NOUN, "cat"); FUNNY = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "funny"); DROLL = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "droll"); }
/** * Main word lookup procedure. First try a normal lookup. If that doesn't work, * try looking up the stemmed form of the lemma. * @param pos the part-of-speech of the word to look up * @param lemma the lemma to look up * @return IndexWord the IndexWord found by the lookup procedure, or null * if an IndexWord is not found */ public IndexWord lookupIndexWord(POS pos, String lemma) throws JWNLException { lemma = prepareQueryString(lemma); IndexWord word = getIndexWord(pos, lemma); if (word == null && getMorphologicalProcessor() != null) { word = getMorphologicalProcessor().lookupBaseForm(pos, lemma); } return word; }
/** * Lookup the base form of a word. Given a lemma, finds the WordNet * entry most like that lemma. This function returns the first base form * found. Subsequent calls to this function with the same part-of-speech * and word will return the same base form. To find another base form for * the pos/word, call lookupNextBaseForm. * @param pos the part-of-speech of the word to look up * @param derivation the word to look up * @return IndexWord the IndexWord found during lookup */ public IndexWord lookupBaseForm(POS pos, String derivation) throws JWNLException { // See if we've already looked this word up LookupInfo info = getCachedLookupInfo(new POSKey(pos, derivation)); if (info != null && info.getBaseForms().isCurrentFormAvailable()) { // get the last base form we retrieved. if you want // the next possible base form, use lookupNextBaseForm return Dictionary.getInstance().getIndexWord(pos, info.getBaseForms().getCurrentForm()); } else { return lookupNextBaseForm(pos, derivation, info); } }