当前位置: 首页>>代码示例>>Java>>正文


Java Redwood.endTrack方法代码示例

本文整理汇总了Java中edu.stanford.nlp.util.logging.Redwood.endTrack方法的典型用法代码示例。如果您正苦于以下问题:Java Redwood.endTrack方法的具体用法?Java Redwood.endTrack怎么用?Java Redwood.endTrack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.util.logging.Redwood的用法示例。


在下文中一共展示了Redwood.endTrack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prettyLog

import edu.stanford.nlp.util.logging.Redwood; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
public void prettyLog(RedwoodChannels channels, String description) {
  Redwood.startTrack(description);

  // sort keys by class name
  List<Class> sortedKeys = new ArrayList<Class>(this.keySet());
  Collections.sort(sortedKeys,
      new Comparator<Class>(){
    @Override
    public int compare(Class a, Class b) {
      return a.getCanonicalName().compareTo(b.getCanonicalName());
    }
  });

  // log key/value pairs
  for (Class key : sortedKeys) {
    String keyName = key.getCanonicalName().replace("class ", "");
    Object value = this.get(key);
    if (PrettyLogger.dispatchable(value)) {
      PrettyLogger.log(channels, keyName, value);
    } else {
      channels.logf("%s = %s", keyName, value);
    }
  }
  Redwood.endTrack(description);
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:31,代码来源:ArrayCoreMap.java

示例2: annotate

import edu.stanford.nlp.util.logging.Redwood; //导入方法依赖的package包/类
/**
 * Annotate a collection of input annotations IN PARALLEL, making use of threads given in numThreads
 * 
 * @param annotations
 *          The input annotations to process
 * @param numThreads
 *          The number of threads to run on
 * @param callback
 *          A function to be called when an annotation finishes. The return value of the callback is ignored.
 */
public void annotate(final Iterable<Annotation> annotations, int numThreads, final Function<Annotation, Object> callback) {
  // case: single thread (no point in spawning threads)
  if (numThreads == 1) {
    for (Annotation ann : annotations) {
      annotate(ann);
      callback.apply(ann);
    }
  }
  // Java's equivalent to ".map{ lambda(annotation) => annotate(annotation) }
  Iterable<Runnable> threads = new Iterable<Runnable>() {
    @Override
    public Iterator<Runnable> iterator() {
      final Iterator<Annotation> iter = annotations.iterator();
      return new Iterator<Runnable>() {
        @Override
        public boolean hasNext() {
          return iter.hasNext();
        }

        @Override
        public Runnable next() {
          if (!iter.hasNext()) {
            throw new NoSuchElementException();
          }
          final Annotation input = iter.next();
          return new Runnable() {
            @Override
            public void run() {
              // (logging)
              String beginningOfDocument = input.toString().substring(0, Math.min(50, input.toString().length()));
              Redwood.startTrack("Annotating \"" + beginningOfDocument + "...\"");
              // (annotate)
              annotate(input);
              // (callback)
              callback.apply(input);
              // (logging again)
              Redwood.endTrack("Annotating \"" + beginningOfDocument + "...\"");
            }
          };
        }

        @Override
        public void remove() {
          iter.remove();
        }
      };
    }
  };
  // Thread
  Redwood.Util.threadAndRun(this.getClass().getSimpleName(), threads, numThreads);
}
 
开发者ID:begab,项目名称:kpe,代码行数:62,代码来源:SzTEAnnotationPipeline.java

示例3: annotate

import edu.stanford.nlp.util.logging.Redwood; //导入方法依赖的package包/类
/**
 * Annotate a collection of input annotations IN PARALLEL, making use of
 * threads given in numThreads
 * @param annotations The input annotations to process
 * @param numThreads The number of threads to run on
* @param callback A function to be called when an annotation finishes.
*                 The return value of the callback is ignored.
 */
public void annotate(final Iterable<Annotation> annotations, int numThreads, final Function<Annotation,Object> callback){
  // case: single thread (no point in spawning threads)
  if(numThreads == 1){
    for(Annotation ann : annotations){
      annotate(ann);
      callback.apply(ann);
    }
  }
  // Java's equivalent to ".map{ lambda(annotation) => annotate(annotation) }
  Iterable<Runnable> threads = new Iterable<Runnable>(){
    public Iterator<Runnable> iterator() {
      final Iterator<Annotation> iter = annotations.iterator();
      return new Iterator<Runnable>(){
        public boolean hasNext() {
          return iter.hasNext();
        }
        public Runnable next() {
          final Annotation input = iter.next();
          return new Runnable(){
            public void run(){
              //Jesus Christ, finally the body of the code
              //(logging)
              String beginningOfDocument = input.toString().substring(0,Math.min(50,input.toString().length()));
              Redwood.startTrack("Annotating \"" + beginningOfDocument + "...\"");
              //(annotate)
              annotate(input);
              //(callback)
              callback.apply(input);
              //(logging again)
              Redwood.endTrack("Annotating \"" + beginningOfDocument + "...\"");
            }
          };
        }
        public void remove() {
          iter.remove();
        }
      };
    }
  };
  // Thread
  Redwood.Util.threadAndRun(this.getClass().getSimpleName(), threads, numThreads );
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:51,代码来源:AnnotationPipeline.java


注:本文中的edu.stanford.nlp.util.logging.Redwood.endTrack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。