这是我的代码

 public static void main(String[] args) {
    String name = "time.stop";
    try {
        StopWordList swl = new StopWordList(name);
        System.out.println(swl.getWords().toString());
        Analyzer az = new StandardAnalyzer(Version.LUCENE_40, swl.getWords());
    } catch (FileNotFoundException ex) {

    }
}


这是错误:线程“ main”中的异常java.lang.Error:未解决的编译问题:
构造函数StandardAnalyzer(Version,Set)是未定义的

at StopWordList.main(StopWordList.java:49)

最佳答案

初始化Analyzer的代码应如下所示:

Analyzer az = new StandardAnalyzer(
  Version.LUCENE_40,
  new CharArraySet(
    Version.LUCENE_40,
    swl.getWords(),
    true
  )
);

07-24 19:00