package com.leixinhui.test;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import com.chenlb.mmseg4j.ComplexSeg;
import com.chenlb.mmseg4j.Dictionary;
import com.chenlb.mmseg4j.MMSeg;
import com.chenlb.mmseg4j.Seg;
import com.chenlb.mmseg4j.Word;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Reader reader = null;
Dictionary dic = null;
Seg seg = null;
MMSeg mmSeg = null;
Word word = null;
reader = new StringReader("我不做C语言程序已经有一段时间了。三聚氰胺、量规等词汇都是专业术语。");
dic = Dictionary.getInstance();
seg = new ComplexSeg(dic);
mmSeg = new MMSeg(reader, seg);
try {
while(null != (word=mmSeg.next())){
System.out.println(word.getString());
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if(null != reader) reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
备注:使用mmseg4j-1.8.5