Package org.snu.ids.ha.util

Examples of org.snu.ids.ha.util.Timer


   
    System.setProperty("DO_DEBUG", "DO_DEBUG");
    try {
      MorphemeAnalyzer ma = new MorphemeAnalyzer();
      ma.createLogger(null);
      Timer timer = new Timer();
      timer.start();
      List<MExpression> ret = ma.analyze(string);
      timer.stop();
      timer.printMsg("Time");

      ret = ma.postProcess(ret);

      ret = ma.leaveJustBest(ret);
View Full Code Here



  public void load(String fileName)
  {
    System.out.println("Loading " + fileName);
    Timer timer = new Timer();
    timer.start();
    BufferedReader br = null;
    try {
      br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
      String line = null;
      while( (line = br.readLine()) != null ) {
        int len = line.length();
        if( len > maxLen ) maxLen = len;
        if( len < minLen ) minLen = len;
        super.add(line);
      }
    } catch (IOException e) {
      System.err.println("Loading Error!");
    } finally {
      timer.stop();
      System.out.println("Loaded " + timer.getInterval() + "secs");
    }
  }
View Full Code Here

   * @param fileName
   */
  public static final void load(String fileName)
  {
    System.out.println("Loading " + fileName);
    Timer timer = new Timer();
    timer.start();

    String line = null;
    BufferedReader br = null;
    try {
      br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));

      while( (line = br.readLine()) != null ) {
        if( !Util.valid(line) || line.startsWith("//") ) continue;
        line = line.trim();
        String[] arr = line.split("\t");
        float[] lnProb = new float[] { Float.parseFloat(arr[2]), Float.parseFloat(arr[3]) };
        PROB_HASH.put(getKey(arr[0], arr[1]), lnProb);
      }
      br.close();
    } catch (Exception e) {
      e.printStackTrace();
      System.err.println(line);
      System.err.println("Unable to load probability dictionary!!");
    } finally {
      timer.stop();
      System.out.println(PROB_HASH.size() + " values are loaded. (Loading time( " + timer.getInterval() + " secs)");
    }
  }
View Full Code Here

   * @param fileName
   */
  static final protected void loadDic(String prefix, String fileName)
  {
    System.out.println("Loading " + fileName);
    Timer timer = new Timer();
    timer.start();

    float lnProb = 0;
    long prevTag = 0, tag = 0;
    String line = null, key = null, str = null;
    String[] arr = null;

    boolean isUni = prefix != null && prefix.equals("UNI");

    BufferedReader br = null;
    try {
      br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));

      while( (line = br.readLine()) != null ) {
        if( !Util.valid(line) || line.startsWith("//") ) continue;
        line = line.trim();

        arr = line.split("\t");

        if( isUni ) {
          // Pr(str,tag)
          if( arr.length == 3 ) {
            str = arr[0];
            tag = POSTag.getTagNum(arr[1]);
            lnProb = Float.parseFloat(arr[2]);
            key = getKey(prefix, 0l, str, tag);
          }
          // Pr(tag)
          else if( arr.length == 2 ) {
            tag = POSTag.getTagNum(arr[0]);
            lnProb = Float.parseFloat(arr[1]);
            key = getKey(prefix, 0l, null, tag);
          }
        } else {
          // Pr(prevTag|str,tag)
          if( arr.length == 4 ) {
            prevTag = POSTag.getTagNum(arr[0]);
            str = arr[1];
            tag = POSTag.getTagNum(arr[2]);
            lnProb = Float.parseFloat(arr[3]);
            key = getKey(prefix, prevTag, str, tag);
          }
          // Pr(prevTag|tag)
          else if( arr.length == 3 ) {
            prevTag = POSTag.getTagNum(arr[0]);
            tag = POSTag.getTagNum(arr[1]);
            lnProb = Float.parseFloat(arr[2]);
            key = getKey(prefix, prevTag, null, tag);
          }
        }

        LN_PROB_HASH.put(key, lnProb);
      }
      br.close();
    } catch (Exception e) {
      e.printStackTrace();
      System.err.println(line);
      System.err.println("Unable to load probability dictionary!!");
    } finally {
      timer.stop();
      System.out.println(LN_PROB_HASH.size() + " values are loaded. (Loading time( " + timer.getInterval() + " secs)");
    }
  }
View Full Code Here

            return;
          }
          try {
            if( ke == null ) createKE();
            startJob("단어 추출");
            Timer timer = new Timer();
            timer.start();
            keywordList = ke.extractKeyword(progressBar, lineLabel, string, onlyNounCheck.isSelected());
            updateTableMode();
            printlog("전체 단어 수: " + keywordList.getDocLen());
            timer.stop();
            endJob(timer.getInterval());
          } catch (Exception e) {
            e.printStackTrace();
          }
        }
      };
View Full Code Here

   * @author  therocks
   * @since  2007. 6. 4
   */
  protected Dictionary()
  {
    Timer timer = new Timer();
    try {
      timer.start();
      loadDic();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      timer.stop();
      timer.printMsg("Dictionary Loading Time");
      System.out.println("Loaded Item " + table.size());
    }
  }
View Full Code Here

   * @since  2009. 10. 20
   */
  public static void reload()
  {
    if( !isLoading && dictionary != null ) {
      Timer timer = new Timer();
      try {
        System.out.println("reloading");
        timer.start();
        dictionary.clear();
        dictionary.loadDic();
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        timer.stop();
        timer.printMsg("Dictionary Loading Time");
        System.out.println("Loaded Item " + dictionary.table.size());
      }
    }
  }
View Full Code Here

   * @param dicReadList
   */
  public static void reload(List<DicReader> dicReadList)
  {
    if( !isLoading && dictionary != null ) {
      Timer timer = new Timer();
      try {
        System.out.println("reloading");
        timer.start();
        dictionary.clear();
        for(int i=0; i < dicReadList.size(); i++) {
          dictionary.load(dicReadList.get(i));
        }
      } catch (Exception e) {
        e.printStackTrace();
      } finally {
        timer.stop();
        timer.printMsg("Dictionary Loading Time");
        System.out.println("Loaded Item " + dictionary.table.size());
      }
    }
  }
View Full Code Here


  void createKE()
  {
    startJob("사전 읽기");
    Timer timer = new Timer();
    timer.start();
    ke = new KeywordExtractor();
    timer.stop();
    endJob(timer.getInterval());
  }
View Full Code Here

        Thread thread = new Thread()
        {
          public void run()
          {
            startJob("사전 다시 읽기");
            Timer timer = new Timer();
            timer.start();
            Dictionary.reload();
            timer.stop();
            endJob(timer.getInterval());
          }
        };
        thread.start();
      }
    }
View Full Code Here

TOP

Related Classes of org.snu.ids.ha.util.Timer

Copyright © 2018 www.massapicom. 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.