2

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.

demongolem
  • 9,474
  • 36
  • 90
  • 105
Master
  • 2,945
  • 5
  • 34
  • 65

1 Answers1

1

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:

sed 's/^\ *//' index.adj | cut -f1 -d\ 

Dot this for all index files: index.adj, index.adv, index.noun, index.sense, index.verb

Amit G
  • 2,293
  • 3
  • 24
  • 44
  • Thanks Amit G. I have already implemented that but for mobile apps that database is too large and frequently querying it over the time is overhead. I have gone through these pointers. I am able to get Antonyms for the word, for which exists in the dictionary. – Master Jan 27 '14 at 14:29
  • Wordnet dictionary has footprint ~35MB, but I think its pretty impressive for more 200K words with their meanings, example usage, semantic and lexical relations. – Amit G Jan 27 '14 at 14:37
  • But as I said frequently querying it for everything might slow down the whole process. And yeah one more thing.If you can help me with, I want the list of all words in sequential order. HOw can I find that. – Master Jan 27 '14 at 14:41
  • you "will" have to access wordnet, there is no escape. Regarding all words: read updated answer. – Amit G Jan 27 '14 at 15:12
  • One Thumbs up for your effort Amit G. But you can get all words of a POS using. IDictionary's getIndexWordIterator(POS); – Master Jan 27 '14 at 17:41
  • "all words" v/s "all words of a POS" got confused. – Amit G Jan 28 '14 at 05:54
  • 2
    Like you want to get all the words(verb) from WOrdNet, in that case pass getIndexWordIterator(POS.VERB); It will return you all the verbs in database. – Master Jan 28 '14 at 07:28
  • thanks @Hoosier for pointing that out. Haven't explored JWI, will. kindly accept the answer if it helped. – Amit G Jan 28 '14 at 13:42
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/46243/discussion-between-hoosier-and-amit-g) – Master Jan 28 '14 at 14:09
  • Its a thumbs up from my side for the information that you provided but I am not going to use it as the way I told you in comment is better. – Master Jan 28 '14 at 14:10