2

我添加了 lucene 3.5.0,当我为雪球分析仪添加一个单独的 jar 时,我收到以下错误:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.lucene.analysis.snowball.SnowballAnalyzer.setOverridesTokenStreamMethod(Ljava/lang/Class;)V
at org.apache.lucene.analysis.snowball.SnowballAnalyzer.<init>(SnowballAnalyzer.java:46)
at org.apache.lucene.analysis.snowball.SnowballAnalyzer.<init>(SnowballAnalyzer.java:61)
at lucene.similarity.rank_stop.main(rank_stop.java:34)

我的代码包括:

Analyzer analyzers = new SnowballAnalyzer(Version.LUCENE_30,"English",StopAnalyzer.ENGLISH_STOP_WORDS_SET); 

private static String analyze(String text) throws IOException {
        int i=0; 
        String result="" ; 
        String[] term = new String[100] ; 
        TokenStream stream = analyzers.reusableTokenStream("contents",new StringReader(text));
        CharTermAttribute charTermAttribute = stream.getAttribute(CharTermAttribute.class);
        while (stream.incrementToken()) {      
            term[i] = charTermAttribute.toString();  
            result+=term[i]+" " ; 
            i++; 
        } 
        return result;  
    }
}
  line2 = analyze(line2); // here line2 is a string that has to be analyzed 

有人可以帮我解决这个问题吗?

4

1 回答 1

2

感谢您的帮助..我有一个兼容的版本...就是这样

于 2012-01-18T03:22:58.843 回答