我的Analyzer没有得到预期的结果,我想测试标记化过程。
这个问题的答案是:How to use a Lucene Analyzer to tokenize a String?
List<String> result = new ArrayList<String>();
TokenStream stream = analyzer.tokenStream(field, new StringReader(keywords));
try {
while(stream.incrementToken()) {
result.add(stream.getAttribute(TermAttribute.class).term());
}
}
catch(IOException e) {
// not thrown b/c we're using a string reader...
}
return result;使用TermAttribute从流中提取令牌。问题是TermAttribute已经不在Lucene6中了。
它被什么取代了?
Lucene 6.6.0会有什么等价物呢?
发布于 2017-06-21 17:05:52
我很确定它被CharTermAttribute javadoc取代了
这张票很旧了,但可能代码保留的时间更长了:https://issues.apache.org/jira/browse/LUCENE-2372
https://stackoverflow.com/questions/44671388
复制相似问题