mmseg4j分词

    mmseg4j分词,所需jar:mmseg4j-analysis-1.9.1.jar,mmseg4j-core-1.9.1.jar。

public class Demo {

	public static void main(String[] args) throws IOException {
		
		String txt  = "十动然拒思密达";
		File file = new File("E:/temp/dic_mmseg");
		//目录下的文件必须是words开头的dic文件,且第一行跳过,写注释
		Dictionary dic = Dictionary.getInstance(file);
		Seg seg = null; 
//		seg = new SimpleSeg(dic); 
		seg = new ComplexSeg(dic); 
//		seg = new MaxWordSeg(dic);
		MMSeg mmSeg = new MMSeg(new StringReader(txt), seg); 
		Word word = null;
		while((word = mmSeg.next())!=null) {			
				if(word != null) {
					System.out.print(word + "|");
			} 
		}
		
	}
}

    词典words.dic内容:

#词典
十动然拒
思密达

猜你喜欢

转载自itace.iteye.com/blog/2125076
今日推荐