diff options
| author | Patrick Simianer <p@simianer.de> | 2011-10-20 02:31:25 +0200 | 
|---|---|---|
| committer | Patrick Simianer <p@simianer.de> | 2011-10-20 02:31:25 +0200 | 
| commit | 92e48b652530d2d2bb4f2694501f95a60d727cb2 (patch) | |
| tree | b484bd0c4216525690de8b14fb654c9581a300c2 /decoder/oracle_bleu.h | |
| parent | 0e70073cec6cdcafaf60d4fbcbd1adf82ae21c8e (diff) | |
| parent | 082b6c77e0703ccd1c85947828c33d4b0eef20f0 (diff) | |
finalized merge
Diffstat (limited to 'decoder/oracle_bleu.h')
| -rwxr-xr-x | decoder/oracle_bleu.h | 22 | 
1 files changed, 15 insertions, 7 deletions
| diff --git a/decoder/oracle_bleu.h b/decoder/oracle_bleu.h index 15d48588..b603e27a 100755 --- a/decoder/oracle_bleu.h +++ b/decoder/oracle_bleu.h @@ -272,23 +272,31 @@ struct OracleBleu {        }        kbest_out<<endl<<flush;        if (show_derivation) { -        deriv_out<<"\nsent_id="<<sent_id<<"\n"; +        deriv_out<<"\nsent_id="<<sent_id<<"."<<i<<" ||| "; //where i is candidate #/k +        deriv_out<<log(d->score)<<"\n";          deriv_out<<kbest.derivation_tree(*d,true); -        deriv_out<<flush; +        deriv_out<<"\n"<<flush;        }      }    }  // TODO decoder output should probably be moved to another file - how about oracle_bleu.h -  void DumpKBest(const int sent_id, const Hypergraph& forest, const int k, const bool unique, std::string const &kbest_out_filename_) { +  void DumpKBest(const int sent_id, const Hypergraph& forest, const int k, const bool unique, std::string const &kbest_out_filename_, std::string const &deriv_out_filename_) {      WriteFile ko(kbest_out_filename_); -    std::cerr << "Output kbest to " << kbest_out_filename_<<std::endl; +    std::cerr << "Output kbest to " << kbest_out_filename_ <<std::endl; +    std::ostringstream sderiv; +    sderiv << deriv_out_filename_; +    if (show_derivation) { +      sderiv << "/derivs." << sent_id; +      std::cerr << "Output derivations to " << deriv_out_filename_ << std::endl; +    } +    WriteFile oderiv(sderiv.str());      if (!unique) -      kbest<KBest::NoFilter<std::vector<WordID> > >(sent_id,forest,k,ko.get(),std::cerr); +      kbest<KBest::NoFilter<std::vector<WordID> > >(sent_id,forest,k,ko.get(),oderiv.get());      else { -      kbest<KBest::FilterUnique>(sent_id,forest,k,ko.get(),std::cerr); +      kbest<KBest::FilterUnique>(sent_id,forest,k,ko.get(),oderiv.get());      }    } @@ -296,7 +304,7 @@ void DumpKBest(std::string const& suffix,const int sent_id, const Hypergraph& fo    {      std::ostringstream kbest_string_stream;      kbest_string_stream << forest_output << "/kbest_"<<suffix<< "." << sent_id; -    DumpKBest(sent_id, forest, k, unique, kbest_string_stream.str()); +    DumpKBest(sent_id, forest, k, unique, kbest_string_stream.str(), "-");    }  }; | 
