/** * Get the IndexWord object for a String and POS */ public synchronized IndexWord getIndexWord(POS pos, String s) throws JWNLException { // This function tries the stemmed form of the lemma return wordnet.lookupIndexWord(pos, s); }
/** * Get the IndexWord object for a String and POS */ public synchronized IndexWord getIndexWord(POS pos, String s) throws JWNLException { // This function tries the stemmed form of the lemma return wordnet.lookupIndexWord(pos, s); }
private void demonstrateMorphologicalAnalysis(String phrase) throws JWNLException { // "running-away" is kind of a hard case because it involves // two words that are joined by a hyphen, and one of the words // is not stemmed. So we have to both remove the hyphen and stem // "running" before we get to an entry that is in WordNet System.out.println("Base form for \"" + phrase + "\": " + Dictionary.getInstance().lookupIndexWord(POS.VERB, phrase)); }
private void demonstrateMorphologicalAnalysis(String phrase) throws JWNLException { // "running-away" is kind of a hard case because it involves // two words that are joined by a hyphen, and one of the words // is not stemmed. So we have to both remove the hyphen and stem // "running" before we get to an entry that is in WordNet System.out.println("Base form for \"" + phrase + "\": " + Dictionary.getInstance().lookupIndexWord(POS.VERB, phrase)); }
private void demonstrateMorphologicalAnalysis(String phrase) throws JWNLException { // "running-away" is kind of a hard case because it involves // two words that are joined by a hyphen, and one of the words // is not stemmed. So we have to both remove the hyphen and stem // "running" before we get to an entry that is in WordNet System.out.println("Base form for \"" + phrase + "\": " + Dictionary.getInstance().lookupIndexWord(POS.VERB, phrase)); }
private void demonstrateMorphologicalAnalysis(String phrase) throws JWNLException { // "running-away" is kind of a hard case because it involves // two words that are joined by a hyphen, and one of the words // is not stemmed. So we have to both remove the hyphen and stem // "running" before we get to an entry that is in WordNet System.out.println("Base form for \"" + phrase + "\": " + Dictionary.getInstance().lookupIndexWord(POS.VERB, phrase)); }
/** * Gets the lemma of a word. * * @param word a word * @param pos part of speech * @return lemma or the input if it could not be lemmatized */ public static String getLemma(String word, POS pos) { if (wDict == null) return word; IndexWord indexWord = null; try { indexWord = wDict.lookupIndexWord(pos, word); } catch (JWNLException e) {} return (indexWord != null) ? indexWord.getLemma() : word; }
protected IndexWord getIndexWord(String lemma, WordNetPartOfSpeech partOfSpeech) throws JWNLException { return doNotProcessThisWord(lemma) ? null : jwnlRealDictionary.lookupIndexWord(JwnlUtils.getJwnlPartOfSpeec(partOfSpeech), lemma); }
public String lemmatize(String word,int pos) { IndexWord indexWord; if(Character.isDigit(word.charAt(word.length()-1))) return word; if(pos>Lemmatiser.LASTPOS || pos<Lemmatiser.FIRSTPOS) return word; try{ indexWord = dict.lookupIndexWord(getPOS(pos), word); if (indexWord != null) return indexWord.getLemma(); else return word; } catch(JWNLException ex) { ex.printStackTrace(); return null; } }
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"); }
public String lemmatize(String word) { IndexWord indexWord; int i; if(Character.isDigit(word.charAt(word.length()-1))) return word; for(i=Lemmatiser.FIRSTPOS;i<=Lemmatiser.LASTPOS;i++){ try { indexWord = dict.lookupIndexWord(getPOS(i), word); if (indexWord != null) return indexWord.getLemma(); } catch (JWNLException ex) { ex.printStackTrace(); return null; } } return word; }
/** * Return a set of <code>IndexWord</code>s, with each element in the set * corresponding to a part-of-speech of <var>word</var>. * @param lemma the word for which to lookup senses * @return An array of IndexWords, each of which is a sense of <var>word</var> */ public IndexWordSet lookupAllIndexWords(String lemma) throws JWNLException { lemma = prepareQueryString(lemma); IndexWordSet set = new IndexWordSet(lemma); for (Iterator itr = POS.getAllPOS().iterator(); itr.hasNext();) { IndexWord current = lookupIndexWord((POS)itr.next(), lemma); if (current != null) set.add(current); } return set; } }
public static List<String> getSynsetsForLemma(String lemma, String pos) { try { synchronized (WordNet.class) { IndexWord indexWord = getDictionary().lookupIndexWord(POS.getPOSForKey(pos), lemma); if (indexWord == null) { return new ArrayList<>(); } Synset[] synsets = indexWord.getSenses(); ArrayList<String> ret = new ArrayList<>(); for (int i = 0; i < synsets.length; i++) { Synset synset = synsets[i]; ret.add(getSynsetID(synset.getOffset(), synset.getPOS().getKey())); } return ret; } } catch (final JWNLException ex) { throw new Error(ex); } }
public List<Synset> getSortedSynsetsOf(String lemma, WordNetPartOfSpeech partOfSpeech) throws WordNetException { if (doNotProcessThisWord(lemma)) return new ArrayList<Synset>(); else { try { net.didion.jwnl.data.IndexWord indexWord = jwnlRealDictionary.lookupIndexWord(JwnlUtils.getJwnlPartOfSpeec(partOfSpeech), lemma); return indexWordToList(indexWord); } catch(JWNLException e) { throw new WordNetException("looking for word <"+lemma+"> with part of speech: "+partOfSpeech.toString()+" failed. See nested exception",e); } } }
public Set<Synset> getSynsetsOf(String lemma, WordNetPartOfSpeech partOfSpeech) throws WordNetException { if (doNotProcessThisWord(lemma)) return new HashSet<Synset>(); else { try { net.didion.jwnl.data.IndexWord indexWord = jwnlRealDictionary.lookupIndexWord(JwnlUtils.getJwnlPartOfSpeec(partOfSpeech), lemma); return indexWordToSet(indexWord); } catch(JWNLException e) { throw new WordNetException("looking for word <"+lemma+"> with part of speech: "+partOfSpeech.toString()+" failed. See nested exception",e); } } }
@Nullable public static String getReadableSynsetID(@Nullable final String synsetID) { if (synsetID == null) { return null; } final Synset synset = getSynset(synsetID); if (synset == null) { throw new IllegalArgumentException("Illegal synset ID " + synsetID); } final String lemma = synset.getWords()[0].getLemma(); final POS pos = POS.getPOSForKey(getPOS(synsetID)); try { final IndexWord word; synchronized (WordNet.class) { word = getDictionary().lookupIndexWord(pos, lemma); } final Synset[] senses = word.getSenses(); for (int i = 0; i < senses.length; ++i) { if (senses[i].equals(synset)) { return lemma + "-" + (i + 1) + pos.getKey(); } } throw new Error("Could not determine sense index for lemma " + lemma + " and synset " + synsetID); } catch (final JWNLException ex) { throw new Error(ex); } // return synset.getSenseKey(lemma); // TODO }