summaryrefslogtreecommitdiff
path: root/decoder/oracle_bleu.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-07-07 18:39:38 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2011-07-07 18:39:38 -0400
commit71daf4bf0b91a247d0d1663ae7850a3db85a378d (patch)
treed47ca0bc9d5ca96deedbbd2c27426be7819ebaea /decoder/oracle_bleu.h
parent75b814cb246052746134f32c723cf6d278b148df (diff)
support for extracting k-best derivation trees
Diffstat (limited to 'decoder/oracle_bleu.h')
-rwxr-xr-xdecoder/oracle_bleu.h22
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(), "-");
}
};