From 190ad8ae1e131ac0e29ff975b0d6502f3cc57af6 Mon Sep 17 00:00:00 2001 From: graehl Date: Mon, 19 Jul 2010 23:40:30 +0000 Subject: fixed oracle generate, detailed score info with --verbose git-svn-id: https://ws10smt.googlecode.com/svn/trunk@329 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/oracle_bleu.h | 2 +- decoder/sentences.h | 32 ++++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'decoder') diff --git a/decoder/oracle_bleu.h b/decoder/oracle_bleu.h index 470d311d..94548c18 100755 --- a/decoder/oracle_bleu.h +++ b/decoder/oracle_bleu.h @@ -115,7 +115,6 @@ struct OracleBleu { set_oracle_doc_size(doc_size); } - typedef boost::shared_ptr ScoreP; ScoreP doc_score,sentscore; // made from factory, so we delete them ScoreP GetScore(Sentence const& sentence,int sent_id) { return ScoreP(ds[sent_id]->ScoreCandidate(sentence)); @@ -185,6 +184,7 @@ struct OracleBleu { } // destroys forest (replaces it w/ rescored oracle one) + // sets sentscore Oracle ComputeOracle(SentenceMetadata const& smeta,Hypergraph *forest_in_out,WeightVector const& feature_weights,unsigned kbest=0,std::string const& forest_output="") { Hypergraph &forest=*forest_in_out; Oracle r; diff --git a/decoder/sentences.h b/decoder/sentences.h index 842072b9..622a6f43 100755 --- a/decoder/sentences.h +++ b/decoder/sentences.h @@ -9,6 +9,10 @@ #include "stringlib.h" typedef std::vector Sentence; +inline std::ostream & operator<<(std::ostream &out,Sentence const& s) { + return out< ss=SplitOnWhitespace(str); @@ -38,15 +42,35 @@ public: Sentences() { } Sentences(unsigned n,Sentence const& sentence) : VS(n,sentence) { } Sentences(unsigned n,std::string const& sentence) : VS(n,StringToSentence(sentence)) { } + std::string filename; void Load(std::string file) { ReadFile r(file); - Load(*r.stream()); + Load(r.get(),file); } - void Load(std::istream &in) { - this->push_back(Sentence()); - while(in>>this->back()) ; + void Load(std::istream &in,std::string filen="-") { + filename=filen; + do { + this->push_back(Sentence()); + } while(in>>this->back()); this->pop_back(); } + void Print(std::ostream &out,int headn=0) const { + out << "[" << size()<< " sentences from "<size(); + if (headn>0&&headn