0

How to get list of nouns according to categories i.e noun.animal (list),noun.plant(list) using JWNL. Example code would be helpful.

Update

I have attached sample code which I think gives me list of noun from noun.animal Lexicographer File.

But nouns are not properly filtered out for proper animal name list. e.g cat,dog,monkey. Instead it gives me following list

0 Animalia

1 recombinant

2 conspecific

3 carrier

.

.

code:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Iterator;
import net.didion.jwnl.JWNL;
import net.didion.jwnl.JWNLException;
import net.didion.jwnl.data.POS;
import net.didion.jwnl.data.Synset;
import net.didion.jwnl.dictionary.Dictionary;

public class AnimalNounListTEST { 

    public static void main(String[] args) throws FileNotFoundException, JWNLException {
        JWNL.initialize(new FileInputStream("config/properties.xml")); 
        final Dictionary dictionary = Dictionary.getInstance();
        Iterator<Synset> nounsList = dictionary.getSynsetIterator(POS.NOUN);
        int i=0;
        while (nounsList.hasNext()) 
        {           
                Synset synset = nounsList.next() ;
                 if(synset.getLexFileName().equals("noun.animal")){
                        System.out.println(i+" "+synset.getWord(0).getLemma() +  " "); 
                        i++;
                 }
        }

    }

}

I am using jwnl-1.4_rc3.jar library for interacting with wordnet dictionary.

Laurel
  • 5,965
  • 14
  • 31
  • 57
Wando
  • 131
  • 1
  • 6
  • 2
    Hi! It would be great if you could add some more information to the question: What have you tried already? Which documentation have you found? Which part of the documentation you have found left you with questions? – hey Jan 22 '20 at 19:08
  • please check updated post. – Wando Jan 22 '20 at 21:29

0 Answers0