I am using www.wordnet.princeton.edu open source dictionary with www.projects.csail.mit.edu/jwi/api/edu/mit/jwi library?
I am unable to find out antonyms of a word. People claim that this is a very good dictionary but I could not find my words in it. I need Antonyms and other related words. Good descriptions and other vocabulary info but I am unable to find what I need.
Here is my code:
List<IWordID> wordIDList = indexWordList.get(0).getWordIDs();
for(int idIndex = 0; idIndex < wordIDList.size(); idIndex++)
{
IWordID wordID = wordIDList.get(idIndex);
IWord word = m_Dict.getWord(wordID);
System.out.println("Id = " + wordID);
System.out.println(" Lemma = " + word.getLemma());
System.out.println(" Gloss = " + word.getSynset().getGloss());
ISynset synset = word.getSynset();
String LexFileName = synset.getLexicalFile().getName();
System.out.println("Lexical Name : " + LexFileName);
/** Finding stem for the word. */
WordnetStemmer stem = new WordnetStemmer(m_Dict);
//System.out.println("test" + stem.findStems(key, POS.NOUN));
ArrayList<String> antonymsList = new ArrayList<String>();
List<IWordID> relatedWords = word.getRelatedWords();
Map<IPointer, List<IWordID>> map = word.getRelatedMap();
AdjMarker marker = word.getAdjectiveMarker();
for (IWordID antonym : word.getRelatedWords()) {
String meaning = m_Dict.getWord(antonym).getLemma();
antonymsList.add(meaning);
System.out.println("Antonym: " + meaning);
System.out.println("Antonym POS: " + m_Dict.getWord(antonym).getPOS());
}
}
What I actually need? :::
I need suggestions on how can I get that relevant information from WordNet. Also, **I am open to accept any other API or library that will provide me the latest version of Dictionary, antonyms, Synonyms and well written description.**
Every suggestion is appreciated.
Use IWord#getRelatedMap to get map
java.util.Map<IPointer,java.util.List<IWordID>>
. This map contain map of relations of current Lemma(word) with other words.Check presence of Pointer#Antonym in this map.
Take a look at wordnet interface Artha to compare correctness of your dictionary lookup result.
There is not direct way of having list of all words. Have used a hack:
Dot this for all index files: index.adj, index.adv, index.noun, index.sense, index.verb