Getting words with JWI and Wordnet

How to use the stem method implemented in MIT JWI (Java API for WordNet) to get the word? I'm not sure how to initialize stem cells and use the findStems method.

+4
source share
3 answers

You do not need an additional library, but you need a dictionary. You can download it from Princeton: https://wordnet.princeton.edu/wordnet/download/current-version/

I recommend downloading only the dictionary from the section "Only for DATABASE WordNet 3.1 files" Extract archive. Assuming PATH / dict is the output location, you can use this code:

Dictionary dict = new Dictionary(new File("PATH/dict")); dict.open(); WordnetStemmer stemmer = new WordnetStemmer(dict); List<String> test = stemmer.findStems("feet", POS.NOUN); for (int i = 0; i < test.size(); i++) { System.out.println(test.get(i)); } 

The output for this example is "foot."

+4
source

This means a comment on sakthi's answer: you really need to determine what POS you are looking for (noun, adjective, verb, etc.) when calling the findStems method (JWI v2.2.3): http://projects.csail.mit.edu /jwi/api/edu/mit/jwi/morph/IStemmer.html

+1
source

Used jar files: edu.mit.jwi_2.1.4.jar and edu.sussex.nlp.jws.beta.11.jar

 JWS ws = new JWS("C:/Program Files/WordNet","2.1"); WordnetStemmer stem = new WordnetStemmer(ws.getDictionary()); System.out.println("test" + stem.findStems("reading") ); 
0
source

All Articles