private void updatePseudoReferences(int epoch){
  if (nbestListWriter != null) {
    nbestListWriter.close();
    EvaluationMetric<IString,String> metric=new BLEUMetric<IString,String>(references);
    MultiTranslationMetricMax<IString,String> searchAlgorithm=new HillClimbingMultiTranslationMetricMax<IString,String>(metric);
    NBestListContainer<IString,String> nbestLists=null;
    try {
      nbestLists=new FlatNBestList(nbestFilename,references.size());
    }
 catch (    IOException e) {
      e.printStackTrace();
      logger.error("Could not load pseudo references from: {}",nbestFilename);
      throw new RuntimeException("Could not load pseudo references from:" + nbestFilename);
    }
    List<ScoredFeaturizedTranslation<IString,String>> maxFeaturizedTranslations=searchAlgorithm.maximize(nbestLists);
    assert maxFeaturizedTranslations.size() == tuneSource.size() : "Pseudo reference set does not match tuning set";
    int numTranslations=maxFeaturizedTranslations.size();
    for (int i=0; i < numTranslations; ++i) {
      Sequence<IString> translation=maxFeaturizedTranslations.get(i).translation;
      if (pseudoReferences.get(i).size() >= numPseudoReferences)       pseudoReferences.get(i).remove(0);
      pseudoReferences.get(i).add(translation);
    }
    logger.info("Number of pseudo references: {}",pseudoReferences.get(0).size());
    File file=new File(nbestFilename);
    file.delete();
    referenceWeights=new double[numReferences + pseudoReferences.get(0).size()];
    Arrays.fill(referenceWeights,1.0);
  }
  if (epoch >= pseudoReferenceBurnIn) {
    nbestFilename=String.format("%s/online-nbest.%d.nbest",tempDirectory,epoch);
    logger.info("Writing nbest lists to: {}",nbestFilename);
    nbestListWriter=IOTools.getWriterFromFile(nbestFilename);
  }
}

private void updatePseudoReferences ( int epoch ) { if ( nbestListWriter != null ) { nbestListWriter . close ( ) ; EvaluationMetric < IString , String > metric = new BLEUMetric < IString , String > ( references ) ; MultiTranslationMetricMax < IString , String > searchAlgorithm = new HillClimbingMultiTranslationMetricMax < IString , String > ( metric ) ; NBestListContainer < IString , String > nbestLists = null ; try { nbestLists = new FlatNBestList ( nbestFilename , references . size ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; logger . error ( "Could not load pseudo references from: {}" , nbestFilename ) ; throw new RuntimeException ( "Could not load pseudo references from:" + nbestFilename ) ; } List < ScoredFeaturizedTranslation < IString , String > > maxFeaturizedTranslations = searchAlgorithm . maximize ( nbestLists ) ; assert maxFeaturizedTranslations . size ( ) == tuneSource . size ( ) : "Pseudo reference set does not match tuning set" ; int numTranslations = maxFeaturizedTranslations . size ( ) ; for ( int i = 0 ; i < numTranslations ; ++ i ) { Sequence < IString > translation = maxFeaturizedTranslations . get ( i ) . translation ; if ( pseudoReferences . get ( i ) . size ( ) >= numPseudoReferences ) pseudoReferences . get ( i ) . remove ( 0 ) ; pseudoReferences . get ( i ) . add ( translation ) ; } logger . info ( "Number of pseudo references: {}" , pseudoReferences . get ( 0 ) . size ( ) ) ; File file = new File ( nbestFilename ) ; file . delete ( ) ; referenceWeights = new double [ numReferences + pseudoReferences . get ( 0 ) . size ( ) ] ; Arrays . fill ( referenceWeights , 1.0 ) ; } if ( epoch >= pseudoReferenceBurnIn ) { nbestFilename = String . format ( "%s/online-nbest.%d.nbest" , tempDirectory , epoch ) ; logger . info ( "Writing nbest lists to: {}" , nbestFilename ) ; nbestListWriter = IOTools . getWriterFromFile ( nbestFilename ) ; } }
update the pseudo - references for this training epoch .
