Small changes to Parameters and StaticData

This commit is contained in:
Hieu Hoang 2014-11-20 11:21:50 +00:00
parent 46596ed49a
commit 8137aeae43
6 changed files with 52 additions and 1 deletions

View File

@ -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<Mmsapt*>(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();

View File

@ -98,6 +98,10 @@ IOWrapper::IOWrapper(const std::vector<FactorType> &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<FactorType> &inputFactorOrder
m_singleBestOutputCollector = new Moses::OutputCollector(&std::cout);
}
/*
const Parameter &params = 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()

View File

@ -268,6 +268,9 @@ public:
// creates a map of TARGET positions which should be replaced by word using placeholder
std::map<size_t, const Moses::Factor*> GetPlaceholders(const Moses::Hypothesis &hypo, Moses::FactorType placeholderFactor);
// post editing
std::ifstream *spe_src, *spe_trg, *spe_aln;
};

View File

@ -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()

View File

@ -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 &paramName) {
bool isParamSpecified(const std::string &paramName) const {
return m_setting.find( paramName ) != m_setting.end();
}

View File

@ -268,6 +268,10 @@ public:
return m_parameter->GetParam(paramName);
}
const Parameter &GetParameter() const {
return *m_parameter;
}
const std::vector<FactorType> &GetInputFactorOrder() const {
return m_inputFactorOrder;
}