diff --git a/moses-cmd/Main.cpp b/moses-cmd/Main.cpp index 7e8a4a0e3..cef8379e1 100644 --- a/moses-cmd/Main.cpp +++ b/moses-cmd/Main.cpp @@ -171,6 +171,32 @@ int main(int argc, char** argv) // execute task #ifdef WITH_THREADS +#ifdef PT_UG + /* + bool spe = params.isParamSpecified("spe-src"); + if (spe) { + // simulated post-editing: always run single-threaded! + task->Run(); + delete task; + string src,trg,aln; + UTIL_THROW_IF2(!getline(ioWrapper->spe_src,src), "[" << HERE << "] " + << "missing update data for simulated post-editing."); + UTIL_THROW_IF2(!getline(ioWrapper->spe_trg,trg), "[" << HERE << "] " + << "missing update data for simulated post-editing."); + UTIL_THROW_IF2(!getline(ioWrapper->spe_aln,aln), "[" << HERE << "] " + << "missing update data for simulated post-editing."); + BOOST_FOREACH (PhraseDictionary* pd, PhraseDictionary::GetColl()) + { + Mmsapt* sapt = dynamic_cast(pd); + if (sapt) sapt->add(src,trg,aln); + VERBOSE(1,"[" << HERE << " added src] " << src << endl); + VERBOSE(1,"[" << HERE << " added trg] " << trg << endl); + VERBOSE(1,"[" << HERE << " added aln] " << aln << endl); + } + } + else + */ +#endif pool.Submit(task); #else task->Run(); diff --git a/moses/IOWrapper.cpp b/moses/IOWrapper.cpp index c195149d8..2a757a1a7 100644 --- a/moses/IOWrapper.cpp +++ b/moses/IOWrapper.cpp @@ -98,6 +98,10 @@ IOWrapper::IOWrapper(const std::vector &inputFactorOrder ,m_detailTreeFragmentsOutputCollector(NULL) ,m_surpressSingleBestOutput(false) + + ,spe_src(NULL) + ,spe_trg(NULL) + ,spe_aln(NULL) { const StaticData &staticData = StaticData::Instance(); @@ -202,6 +206,16 @@ IOWrapper::IOWrapper(const std::vector &inputFactorOrder m_singleBestOutputCollector = new Moses::OutputCollector(&std::cout); } + /* + const Parameter ¶ms = staticData.GetParameter(); + bool spe = params.isParamSpecified("spe-src"); + if (spe) { + spe_src->open(params.GetParam("spe-src")[0]); + spe_trg->open(params.GetParam("spe-trg")[0]); + spe_aln->open(params.GetParam("spe-aln")[0]); + } + */ + } IOWrapper::~IOWrapper() diff --git a/moses/IOWrapper.h b/moses/IOWrapper.h index 41254c627..4253871b3 100644 --- a/moses/IOWrapper.h +++ b/moses/IOWrapper.h @@ -268,6 +268,9 @@ public: // creates a map of TARGET positions which should be replaced by word using placeholder std::map GetPlaceholders(const Moses::Hypothesis &hypo, Moses::FactorType placeholderFactor); + // post editing + std::ifstream *spe_src, *spe_trg, *spe_aln; + }; diff --git a/moses/Parameter.cpp b/moses/Parameter.cpp index 687703e28..6dae08900 100644 --- a/moses/Parameter.cpp +++ b/moses/Parameter.cpp @@ -207,6 +207,10 @@ Parameter::Parameter() AddParam("default-non-term-for-empty-range-only", "Don't add [X] to all ranges, just ranges where there isn't a source non-term. Default = false (ie. add [X] everywhere)"); AddParam("s2t", "Use specialized string-to-tree decoder."); AddParam("s2t-parsing-algorithm", "Which S2T parsing algorithm to use. 0=recursive CYK+, 1=scope-3 (default = 0)"); + + AddParam("spe-src", "Simulated post-editing. Source filename"); + AddParam("spe-trg", "Simulated post-editing. Target filename"); + AddParam("spe-aln", "Simulated post-editing. Alignment filename"); } Parameter::~Parameter() diff --git a/moses/Parameter.h b/moses/Parameter.h index 0eb06cc10..5b2c1cc60 100644 --- a/moses/Parameter.h +++ b/moses/Parameter.h @@ -94,7 +94,7 @@ public: return m_setting[paramName]; } /** check if parameter is defined (either in moses.ini or as switch) */ - bool isParamSpecified(const std::string ¶mName) { + bool isParamSpecified(const std::string ¶mName) const { return m_setting.find( paramName ) != m_setting.end(); } diff --git a/moses/StaticData.h b/moses/StaticData.h index 7d87b2df7..feb6c8c85 100644 --- a/moses/StaticData.h +++ b/moses/StaticData.h @@ -268,6 +268,10 @@ public: return m_parameter->GetParam(paramName); } + const Parameter &GetParameter() const { + return *m_parameter; + } + const std::vector &GetInputFactorOrder() const { return m_inputFactorOrder; }