【发布时间】:2016-11-25 13:02:19
【问题描述】:
我使用的是雪球词干分析器,可以在这里找到http://snowball.tartarus.org/
我正在使用这个论坛问题为我自己的项目使用词干算法
Is there a java implementation of Porter2 stemmer
我使用给定的类并使用之前回答的帖子中给出的代码
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
真的不知道如何解决这个问题
【问题讨论】:
-
标题中的错误消息不会出现在问题的任何地方。请修复它。
标签: java error-handling porter-stemmer