IK分詞器的使用


  1. 使用的包:ik-analyzer-5.01-for solr4.3.jar

  2. 直接導入即可使用
  3.   
  4. import java.io.IOException;  
  5. import java.io.StringReader;  
  6.   
  7. import org.wltea.analyzer.core.IKSegmenter;  
  8. import org.wltea.analyzer.core.Lexeme;  
  9.   
  10. public class Test3 {  
  11.       
  12.     public static void main(String[] args) throws IOException {  
  13.         String text="基於java語言開發的輕量級的中文分詞工具包";  
  14.         StringReader sr=new StringReader(text);  
  15.         IKSegmenter ik=new IKSegmenter(sr, true);  
  16.         Lexeme lex=null;  
  17.         while((lex=ik.next())!=null){  
  18.             System.out.print(lex.getLexemeText()+"|");  
  19.         }  
  20.     }  
  21.   
  22. }  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章