lucene实现全文检索(四):分词器
生活随笔
收集整理的這篇文章主要介紹了
lucene实现全文检索(四):分词器
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
關于分詞器的比較和選擇,可以看這篇文章:Lucene的各中文分詞比較
doToken()方法可以對傳入的字符串進行分詞
/***** @param ts 需要拆詞的字符串* @return* @throws IOException*/public static List<String> doToken(TokenStream ts) throws IOException {List<String> stringList = new ArrayList<>();ts.reset();CharTermAttribute cta = ts.getAttribute(CharTermAttribute.class);while (ts.incrementToken()) {stringList.add(cta.toString());}System.out.println();ts.end();ts.close();return stringList;}總結
以上是生活随笔為你收集整理的lucene实现全文检索(四):分词器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 子网划分
- 下一篇: 2024-01-17:lc的30. 串联