lucene - Stemming text in java -


this question has answer here:

im searching possibility stemm strings in java. first wanted lucene examples found in web deprecated. (snowballanalyzer, porterstemmer, ...) want stemm whole sentences.

public static string stemsentence(string sentence) {     ...     return stemmedsentence; } 

how can it?

make this:

public static string stem(string string) throws ioexception {     tokenstream tokenizer = new standardtokenizer(version.lucene_47, new stringreader(string));     tokenizer = new standardfilter(version.lucene_47, tokenizer);     tokenizer = new lowercasefilter(version.lucene_47, tokenizer);     tokenizer = new porterstemfilter(tokenizer);      chartermattribute token = tokenizer.getattribute(chartermattribute.class);      tokenizer.reset();      stringbuilder stringbuilder = new stringbuilder();      while(tokenizer.incrementtoken()) {         if(stringbuilder.length() > 0 ) {             stringbuilder.append(" ");         }          stringbuilder.append(token.tostring());     }      tokenizer.end();     tokenizer.close();      return stringbuilder.tostring(); } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -