我正在使用可以在这里找到的雪球词干分析器http://snowball.tartarus.org/
我正在使用这个论坛问题为我自己的项目使用词干算法
我使用给定的类并使用之前回答的帖子中给出的代码
Class stemClass = Class.forName("org.tartarus.snowball.ext." + lang + "Stemmer");
stemmer = (SnowballProgram) stemClass.newInstance();
stemmer.setCurrent("your_word");
stemmer.stem();
String your_stemmed_word = stemmer.getCurrent();
但是当我开始使用 try catch 语句时,我得到了这个错误
assmt1/invert3.java:339: error: incompatible types: try-with-resources not applicable to variable type
try( Class stemClass = Class.forName("org.tartarus.snowball.ext." +"english"+ "Stemmer");
^
(Class cannot be converted to AutoCloseable)
assmt1/invert3.java:340: error: incompatible types: try-with-resources not applicable to variable type
SnowballStemmer stemmer = (SnowballStemmer) stemClass.newInstance())
^
(SnowballStemmer cannot be converted to AutoCloseable)
2 errors
真的不知道如何解决这个问题