public void testDictSegmentSearch(){
InputStream is = DictionaryTester.class.getResourceAsStream(Dictionary.PATH_DIC_MAIN);
System.out.println(new Date() + " before load dictionary");
DictSegment _root_ = new DictSegment((char)0);
List<String> allWords = new ArrayList<String>();
System.out.println(new Date() + " loading dictionary");
try {
String theWord = null;
BufferedReader br = new BufferedReader(new InputStreamReader(is , "UTF-8"), 512);
do {
theWord = br.readLine();
if (theWord != null) {
allWords.add(theWord.trim());
_root_.fillSegment(theWord.trim().toCharArray());
}
} while (theWord != null);
System.out.println(new Date() + " after load dictionary");
} catch (IOException ioe) {
System.err.println("主词典库载入异常.");
ioe.printStackTrace();
}finally{
try {
if(is != null){
is.close();
is = null;
}
} catch (IOException e) {
e.printStackTrace();
}
}
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println(new Date() + " begin march");
long begintime = System.currentTimeMillis();
Hit hit = null;
int umCount = 0;
int mCount = 0;
for(String word : allWords){
char[] chars = word.toCharArray();
hit = _root_.match(chars , 0, chars.length);
if(hit.isUnmatch()){
//System.out.println(word);
umCount++;
}else{
mCount++;