public String toString() { String str; if (size() == 0) { str = "<empty>"; } else { StringBuilder buf = new StringBuilder(); for (POS o : getValidPOSSet()) { buf.append(getIndexWord(o).toString()); } str = buf.toString(); } return ResourceBundleSet.insertParams("[IndexWordSet: {0}]", new String[]{str}); }
private static IndexWord[] getWordArray(String word) throws JWNLException { if (dictionary == null) { throw exc; } return dictionary.lookupAllIndexWords(word).getIndexWordArray(); }
/** * It is assumed that IndexWordSets will only be created by calling * {@link net.sf.extjwnl.dictionary.Dictionary#lookupAllIndexWords Dictionary.lookupAllIndexWords}, * so all IndexWordSets with the same lemma should be equal. */ @Override public boolean equals(Object object) { return (object instanceof IndexWordSet) && getLemma().equals(((IndexWordSet) object).getLemma()); }
/** * Finds out how many senses the word with part-of-speech <var>pos</var> has. * * @param pos POS * @return number of senses the word with part-of-speech <var>pos</var> has */ public int getSenseCount(POS pos) { int result = 0; IndexWord indexWord = getIndexWord(pos); if (null != indexWord) { result = indexWord.getSenses().size(); } return result; }
/** * Returns 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> * @throws JWNLException JWNLException */ public IndexWordSet lookupAllIndexWords(String lemma) throws JWNLException { lemma = prepareQueryString(lemma); IndexWordSet set = new IndexWordSet(lemma); for (POS pos : POS.getAllPOS()) { IndexWord current = lookupIndexWord(pos, lemma); if (current != null) { set.add(current); } } return set; }
/** * Finds out how many senses the word with part-of-speech <var>pos</var> has. * * @param pos POS * @return number of senses the word with part-of-speech <var>pos</var> has */ public int getSenseCount(POS pos) { int result = 0; IndexWord indexWord = getIndexWord(pos); if (null != indexWord) { result = indexWord.getSenses().size(); } return result; }
/** * Returns 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> * @throws JWNLException JWNLException */ public IndexWordSet lookupAllIndexWords(String lemma) throws JWNLException { lemma = prepareQueryString(lemma); IndexWordSet set = new IndexWordSet(lemma); for (POS pos : POS.getAllPOS()) { IndexWord current = lookupIndexWord(pos, lemma); if (current != null) { set.add(current); } } return set; }
public String toString() { String str; if (size() == 0) { str = "<empty>"; } else { StringBuilder buf = new StringBuilder(); for (POS o : getValidPOSSet()) { buf.append(getIndexWord(o).toString()); } str = buf.toString(); } return ResourceBundleSet.insertParams("[IndexWordSet: {0}]", new String[]{str}); }
public Map<WordNetPartOfSpeech, List<Synset>> getSortedSynsetOf(String lemma) throws WordNetException { Map<WordNetPartOfSpeech, List<Synset>> ret = new LinkedHashMap<WordNetPartOfSpeech, List<Synset>>(); if (doNotProcessThisWord(lemma)) ; else { try { IndexWordSet indexWordSet = extJwnlRealDictionary.lookupAllIndexWords(lemma); if (indexWordSet!=null) { for (WordNetPartOfSpeech partOfSpeech : WordNetPartOfSpeech.values()) { POS pos = ExtJwnlUtils.getJwnlPartOfSpeec(partOfSpeech); if (indexWordSet.getIndexWord(pos)!=null) ret.put(partOfSpeech, indexWordToList(indexWordSet.getIndexWord(pos))); } } } catch(JWNLException e) { throw new WordNetException("looking for lemma <"+lemma+"> failed. See nested exception",e); } } return ret; }
@Override public boolean containsLexeme(String lexeme) throws LexicalSemanticResourceException { if (lexeme == null) { return false; } try { //zhu case sensitivity IndexWord[] indexWords = dict.lookupAllIndexWords(lexeme).getIndexWordArray(); for (IndexWord item : indexWords){ //TODO how to do if the lookupAllIndexWords returns a stemmed form? if(isCaseSensitive){ if(item.getLemma().equals(lexeme)) { return true; } }else{ if(item.getLemma().equalsIgnoreCase(lexeme)) { return true; } } } } catch (JWNLException e) { throw new LexicalSemanticResourceException(e); } return false; }
/** * It is assumed that IndexWordSets will only be created by calling * {@link net.sf.extjwnl.dictionary.Dictionary#lookupAllIndexWords Dictionary.lookupAllIndexWords}, * so all IndexWordSets with the same lemma should be equal. */ @Override public boolean equals(Object object) { return (object instanceof IndexWordSet) && getLemma().equals(((IndexWordSet) object).getLemma()); }
public Map<WordNetPartOfSpeech, Set<Synset>> getSynsetOf(String lemma) throws WordNetException { Map<WordNetPartOfSpeech, Set<Synset>> ret = new LinkedHashMap<WordNetPartOfSpeech, Set<Synset>>(); if (doNotProcessThisWord(lemma)) ; else { try { IndexWordSet indexWordSet = extJwnlRealDictionary.lookupAllIndexWords(lemma); if (indexWordSet!=null) { for (WordNetPartOfSpeech partOfSpeech : WordNetPartOfSpeech.values()) { POS pos = ExtJwnlUtils.getJwnlPartOfSpeec(partOfSpeech); if (indexWordSet.getIndexWord(pos)!=null) ret.put(partOfSpeech, indexWordToSet(indexWordSet.getIndexWord(pos))); } } } catch(JWNLException e) { throw new WordNetException("looking for lemma <"+lemma+"> failed. See nested exception",e); } } return ret; }