使用Lucene和IKAnalyzer做简单的字符串分词

import java.io.IOException;
import java.io.StringReader;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

public class LucenceTest {

	public static void main(String[] args) throws IOException{
		String text="基回家 hello";  
	       StringReader sr=new StringReader(text);  
	       IKSegmenter ik=new IKSegmenter(sr, true);  
	       Lexeme lex=null;  
	       while((lex=ik.next())!=null){  
	           System.out.print(lex.getLexemeText()+"|");  
	       }   

		}
}


你可能感兴趣的:(使用Lucene和IKAnalyzer做简单的字符串分词)