标签:查看 param article cep exce add tac ref 字符串
/** * 获取分词结果 * @param 输入的字符串 * @param 分词器 * @return 分词结果 */ public static List<String> getWords(String str,Analyzer analyzer){ List<String> result = new ArrayList<String>(); TokenStream stream = null; try { stream = analyzer.tokenStream("content", new StringReader(str)); CharTermAttribute attr = stream.addAttribute(CharTermAttribute.class); stream.reset(); while(stream.incrementToken()){ result.add(attr.toString()); } } catch (IOException e) { e.printStackTrace(); }finally{ if(stream != null){ try { stream.close(); } catch (IOException e) { e.printStackTrace(); } } } return result; }
标签:查看 param article cep exce add tac ref 字符串
原文地址:http://www.cnblogs.com/lxl57610/p/7571595.html