Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2014-11-20 14:21:50 +0300
committerHieu Hoang <hieuhoang@gmail.com>2014-11-20 14:21:50 +0300
commit8137aeae43d187e7a324e8c1a490f1d8365a8876 (patch)
tree87436fcc787a6621e16a90ecbcb8926f47a46e05
parent46596ed49a63c5b76f822b3dfff6f10c4da5ef22 (diff)
Small changes to Parameters and StaticData
-rw-r--r--moses-cmd/Main.cpp26
-rw-r--r--moses/IOWrapper.cpp14
-rw-r--r--moses/IOWrapper.h3
-rw-r--r--moses/Parameter.cpp4
-rw-r--r--moses/Parameter.h2
-rw-r--r--moses/StaticData.h4
6 files changed, 52 insertions, 1 deletions
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<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();
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<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()
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<size_t, const Moses::Factor*> 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 &paramName) {
+ bool isParamSpecified(const std::string &paramName) 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<FactorType> &GetInputFactorOrder() const {
return m_inputFactorOrder;
}