Package joshua.discriminative.training.risk_annealer.hypergraph.parallel

Source Code of joshua.discriminative.training.risk_annealer.hypergraph.parallel.HGProducer

/**
*
*/
package joshua.discriminative.training.risk_annealer.hypergraph.parallel;

import java.util.concurrent.BlockingQueue;
import java.util.logging.Logger;

import joshua.discriminative.training.parallel.Producer;
import joshua.discriminative.training.risk_annealer.hypergraph.HGAndReferences;
import joshua.discriminative.training.risk_annealer.hypergraph.HyperGraphFactory;

public class HGProducer extends Producer<HGAndReferences>{
  private  HyperGraphFactory hgFactory;
  private int maxSentID;
  private int curSentID = 0;
 
   /** Logger for this class. */
  private static final Logger logger =
    Logger.getLogger(HGProducer.class.getName());
 
  public HGProducer( HyperGraphFactory hgFactory, BlockingQueue<HGAndReferences> q, int numConsumers,
      int maxSentID) {
    super(q, numConsumers);
    this.hgFactory = hgFactory;
    this.maxSentID = maxSentID; 
  }

  @Override
  public HGAndReferences createPoisonObject() {
    return new HGAndReferences(null, null);
  }

 
  @Override
  public HGAndReferences produce() {
   
    HGAndReferences res = null;
    if(curSentID<maxSentID){
      res  = hgFactory.nextHG();
                   
      curSentID++;       
      if(curSentID%1000==0){
         logger.info("======produce sentID =" + curSentID);
      }
   
    }
    return res;
  }
}
TOP

Related Classes of joshua.discriminative.training.risk_annealer.hypergraph.parallel.HGProducer

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.