I use the java jwi API to search in wordnet to get synonyms for a word. The problem is that he gives me only one result to find his synonyms. Please guide me. Is it possible to get a list of all possible synonyms for a given word? My code is:
public void searcher() {
try {
url = new URL("file", null, path);
dict = new Dictionary(url);
try {
dict.open();
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Dictionary directory does not exist\n" + ex + "\nClass:Meaning Thread", "Dictionary Not Found Error", JOptionPane.ERROR_MESSAGE);
}
IIndexWord idxWord = dict.getIndexWord("capacity", POS.NOUN);
IWordID wordID = idxWord.getWordIDs().get(0);
IWord word = dict.getWord(wordID);
ISynset synset = word.getSynset();
for (IWord w : synset.getWords()) {
System.out.println(w.getLemma());
}
} catch (Exception e) {
}
}
Output only:
capacity
myself! Actual synonyms should be:
capability
capacitance
content
electrical capacitance
mental ability...(so on)
So is there something that I missed in the code, or can someone give me some ideas, what is the problem?
Thanks in advance
source
share