/**
* 得到分词list
*
* @param text
* @param analyzer
* @return
*/
public static List<String> getIkFc(String text, Analyzer analyzer) {
StringReader reader = new StringReader(text);
List<String> list = new ArrayList<String>();
TokenStream ts;
try {
ts = analyzer.tokenStream("", reader);
CharTermAttribute term = ts.getAttribute(CharTermAttribute.class);
ts.reset();//lucene 4.6以上要加这个,4.6以前不需要,本人测试的是4.2 .0不需要,4.10.4需要
while (ts.incrementToken()) {
list.add(term.toString());
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(list);
reader.close();
return list;
}