Search code examples
javamachine-learningnlpopennlpporter-stemmer

Built-in Porter Stemmer in java opennlp toolkit


Like there are built in Stemmers like porter Stemmer in python nltk (https://stackoverflow.com/a/10369407/3096792 ), I want to know if there is any built-in Porter Stemmer in java apache opennlp though there is an interface under this package [opennlp.tools.stemmer.Stemmer]. Since I dont know or need to know the algorithm behind stemming as of now,I need a standard package under apache opennlp toolkit. If not present, whats the alternative in java ?


Solution

  • You can use Apache Lucene Snowball Library here

    Just put this jar file inside your build path and use it

    PorterStemmer stemmer = new PorterStemmer();
    stemmer.setCurrent(input); //set string you need to stem
    stemmer.stem();  //stem the word
    stemmer.getCurrent();//get the stemmed word