0

i have tried to implemented class IndonesianAnalyzer from library org.apache.lucene.analysis.id.*; now i have a problem how to use initialize class indonesian analyzer to my project ,, my code like this ???

 import java.io.*;
 import org.apache.lucene.analysis.*;
 import org.apache.lucene.analysis.snowball.*;
 import org.apache.lucene.analysis.id.*;

 public class exampleText {
public static String Stem(String text, String language){
    StringBuffer result = new StringBuffer();
    if (text!=null && text.trim().length()>0){
        StringReader tReader = new StringReader(text);
        IndonesianAnalyzer analyzer = new IndonesianAnalyzer(matchVersion);
        TokenStream tStream = analyzer.tokenStream("contents", tReader);
        TermAttribute term = tStream.addAttribute(TermAttribute.class);

        try {
            while (tStream.incrementToken()){
                result.append(term.term());
                result.append(" ");
            }
        } catch (IOException ioe){
            System.out.println("Error: "+ioe.getMessage());
        }
    }


    if (result.length()==0)
        result.append(text);
    return result.toString().trim();
 }
  • Maybe it's because matchVersion doesn't exist? – Timon de Groot Jun 04 '14 at 18:11
  • If the error is on the `IndonesianAnalyzer` ctor, the version argument would likely be it, unless the matchVersion is defined later. Exactly what is the problem you are running into? – femtoRgon Jun 04 '14 at 19:16

0 Answers0