Weka 雪球不工作

Weka Snowball not working

我正在尝试使用 Weka 的 StringToWordVector 创建一个带有 Weka 的意大利语文本分类器来创建特征。

分类器工作正常,但我将词干提取器设置为过滤器的一个选项,但它不起作用。 这是我的代码:

SnowballStemmer sb=new SnowballStemmer();
snowball.setStemmer("italian");

StringToWordVector str2Words = new StringToWordVector();
String[] options_wordVector = { /*other options*/};
str2Words.setOptions(options_wordVector); 
str2Words.setStemmer(sb);

当我开始调试时在控制台出现日志

Stemmer 'italian' unknown!

我也试过sb.stem(string),但出现了同样的信息,结果字符串是开始的。

我怎样才能让它发挥作用?

已解决。

我误解了 Weka's stemmers docs:在 weka.jar 中它存在 weka.core.stemmers package,但它只包含包装器 class。

The Snowball classes are not included, they only have to be present in the classpath. The reason for this is, that the Weka team doesn't have to watch out for new versions of the stemmers and update them.

问题中的代码在 class 路径中包含词干分析器后实际上有效。