AbstractListProcessor.java :  » Natural-Language-Processing » Stanford-Chinese-Word-Segmenter » edu » stanford » nlp » process » Java Open Source

Java Open Source » Natural Language Processing » Stanford Chinese Word Segmenter 
Stanford Chinese Word Segmenter » edu » stanford » nlp » process » AbstractListProcessor.java
package edu.stanford.nlp.process;


import edu.stanford.nlp.util.Function;


import edu.stanford.nlp.util.Function;

import edu.stanford.nlp.ling.Document;

import java.util.ArrayList;
import java.util.List;

/**
 * Class AbstractListProcessor
 *
 * @author Teg Grenager
 */
public abstract class AbstractListProcessor<IN,OUT> implements ListProcessor<IN,OUT>, Processor<IN,OUT> {

  public AbstractListProcessor() {
  }

  public Document<OUT> processDocument(Document<IN> in) {
    Document<OUT> doc = in.blankDocument();
    doc.addAll(process(in));
    return doc;
  }

  /** Process a list of lists of tokens.  For example this might be a
   *  list of lists of words.
   *
   * @param lists a List of objects of type List
   * @return a List of objects of type List, each of which has been processed.
   */
  public List<List<OUT>> processLists(List<List<IN>> lists) {
    List<List<OUT>> result = new ArrayList<List<OUT>>(lists.size());
    for (List<IN> list : lists) {
      List<OUT> outList = process(list);
      result.add(outList);
    }
    return result;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.