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.