/** * Ctor with an {@link Word} and a dictionary This Ctor is quicker than the other. * * @param jwiDictionary * @throws WordNetException */ ExtJwnlSensedWord(Word wordObj, ExtJwnlDictionary extJwnlDictionary) throws WordNetException { if (wordObj == null) throw new WordNetException("wordObj is null!"); this.wordObj = wordObj; this.synset = new ExtJwnlSynset(extJwnlDictionary, wordObj.getSynset()); this.word = wordObj.getLemma(); this.dictionary = extJwnlDictionary; this.pos = ExtJwnlUtils.getWordNetPartOfSpeech(wordObj.getPOS()); }
/** * Ctor that takes a synset and a word. It verifies that the word indeed belongs to the synset. * * <p><b>NOTE</b> ExtJwnl <i>lowercases</i> the words it is queried about. But the words it * retrieves in methods like <code>realSynset.getWords()</code> are case sensitive! * * @param synset * @param strWord * @throws WordNetException */ public ExtJwnlSensedWord(ExtJwnlSynset synset, String strWord) throws WordNetException { this.synset = synset; this.word = strWord; String wordToLookup = strWord.replace( ' ', '_'); // mimic jwnl, which replaces underscores with spaces when looking up List<Word> words = synset.realSynset.getWords(); Word wordObj = lookupWordInWords(words, wordToLookup); if (wordObj == null) throw new WordNetException( "\"" + strWord + "\" is not a memeber of the given synset " + synset); this.wordObj = wordObj; dictionary = synset.extJwnlDictionary; this.pos = ExtJwnlUtils.getWordNetPartOfSpeech(wordObj.getPOS()); }