Examples of DictSegment


Examples of org.wltea.analyzer.dic.DictSegment

  }
 
  public void testMainDictMemoryConsume(){
        InputStream is = DictionaryTester.class.getResourceAsStream(Dictionary.PATH_DIC_MAIN);
        System.out.println(new Date() + " before load dictionary");
        DictSegment _root_ = new DictSegment((char)0);
        try {
      Thread.sleep(20000);
    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
        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) {
          _root_.fillSegment(theWord.toCharArray());
        }
      } while (theWord != null);
      System.out.println(new Date() + " after load dictionary");

 
View Full Code Here

Examples of org.wltea.analyzer.dic.DictSegment

 
  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++;
View Full Code Here

Examples of org.wltea.analyzer.dic.DictSegment

  }
 
  public void testMainDictMemoryConsume(){
        InputStream is = DictionaryTester.class.getResourceAsStream(Dictionary.PATH_DIC_MAIN);
        System.out.println(new Date() + " before load dictionary");
        DictSegment _root_ = new DictSegment((char)0);
        try {
      Thread.sleep(20000);
    } catch (InterruptedException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
        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) {
          _root_.fillSegment(theWord.toCharArray());
        }
      } while (theWord != null);
      System.out.println(new Date() + " after load dictionary");

 
View Full Code Here

Examples of org.wltea.analyzer.dic.DictSegment

 
  public void testDictSegmentSearch(){
        InputStream is = DictionaryTester.class.getResourceAsStream(Dictionary.PATH_DIC_QUANTIFIER);
        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){     
      hit = _root_.match(word.toCharArray());
      if(hit.isUnmatch()){
        System.out.println(word);
        umCount++;
      }else{
        mCount++;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.