summaryrefslogtreecommitdiff
path: root/mteval/scorer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'mteval/scorer.cc')
-rw-r--r--mteval/scorer.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/mteval/scorer.cc b/mteval/scorer.cc
index a83b9e2f..ced0cadf 100644
--- a/mteval/scorer.cc
+++ b/mteval/scorer.cc
@@ -595,6 +595,7 @@ void DocScorer::Init(
const vector<string>& ref_files,
const string& src_file, bool verbose) {
scorers_.clear();
+ this->type = type;
// TODO stop using valarray, start using ReadFile
cerr << "Loading references (" << ref_files.size() << " files)\n";
ReadFile srcrf;
@@ -644,3 +645,27 @@ void DocScorer::Init(
cerr << "Loaded reference translations for " << scorers_.size() << " sentences.\n";
}
+void DocStreamScorer::Init(
+ const ScoreType type,
+ const vector<string>& ref_files,
+ const string& src_file, bool verbose) {
+ scorers_.clear();
+ // AER not supported in stream mode
+ assert(type != AER);
+ this->type = type;
+ vector<vector<WordID> > refs(1);
+ string src_line;
+ // Empty reference 0
+ TD::ConvertSentence("", &refs[0]);
+ scorers_.push_back(ScorerP(SentenceScorer::CreateSentenceScorer(type, refs, src_line)));
+ // Reference 1 starts empty, updated as needed
+ scorers_.push_back(ScorerP(SentenceScorer::CreateSentenceScorer(type, refs, src_line)));
+}
+
+void DocStreamScorer::update(const std::string& ref) {
+ scorers_.pop_back();
+ vector<vector<WordID> > refs(1);
+ string src_line;
+ TD::ConvertSentence(ref, &refs[0]);
+ scorers_.push_back(ScorerP(SentenceScorer::CreateSentenceScorer(this->type, refs, src_line)));
+}