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 <fishandfrolick@gmail.com>2013-06-10 21:11:55 +0400
committerHieu Hoang <fishandfrolick@gmail.com>2013-06-10 21:11:55 +0400
commitabe6bb7c2257cce6ed746e54fdd97fbf1f1ef3aa (patch)
tree5cff23f9434a2bd500ee55c4839e753cc119388c /moses/TranslationModel/PhraseDictionary.cpp
parent96d116dba09f4c29fbbfa1edd3d52a31a4b74b49 (diff)
refactor parsing of feature functiona args
Diffstat (limited to 'moses/TranslationModel/PhraseDictionary.cpp')
-rw-r--r--moses/TranslationModel/PhraseDictionary.cpp39
1 files changed, 19 insertions, 20 deletions
diff --git a/moses/TranslationModel/PhraseDictionary.cpp b/moses/TranslationModel/PhraseDictionary.cpp
index 22802f6b5..66b5ddff8 100644
--- a/moses/TranslationModel/PhraseDictionary.cpp
+++ b/moses/TranslationModel/PhraseDictionary.cpp
@@ -32,24 +32,18 @@ namespace Moses
PhraseDictionary::PhraseDictionary(const std::string &description, const std::string &line)
:DecodeFeature(description, line)
+ ,m_tableLimit(20) // default
{
- m_tableLimit= 20; // TODO default?
-
- for (size_t i = 0; i < m_args.size(); ++i) {
- const vector<string> &args = m_args[i];
-
- if (args[0] == "path") {
- m_filePath = args[1];
- } else if (args[0] == "table-limit") {
- m_tableLimit = Scan<size_t>(args[1]);
- } else if (args[0] == "target-path") {
- m_targetFile = args[1];
- } else if (args[0] == "alignment-path") {
- m_alignmentsFile = args[1];
+ size_t ind = 0;
+ while (ind < m_args.size()) {
+ vector<string> &args = m_args[ind];
+ bool consumed = OverrideParameter(args[0], args[1]);
+ if (consumed) {
+ m_args.erase(m_args.begin() + ind);
} else {
- //throw "Unknown argument " + args[0];
+ ++ind;
}
- } // for (size_t i = 0; i < toks.size(); ++i) {
+ }
// find out which feature function can be applied in this decode step
const std::vector<FeatureFunction*> &allFeatures = FeatureFunction::GetFeatureFunctions();
@@ -72,11 +66,16 @@ GetTargetPhraseCollection(InputType const& src,WordsRange const& range) const
bool PhraseDictionary::OverrideParameter(const std::string& key, const std::string& value)
{
- if (key == "table-limit") {
- m_tableLimit = Scan<size_t>(value);
- }
- else {
- return DecodeFeature::OverrideParameter(key, value);
+ if (key == "path") {
+ m_filePath = value;
+ } else if (key == "table-limit") {
+ m_tableLimit = Scan<size_t>(value);
+ } else if (key == "target-path") {
+ m_targetFile = value;
+ } else if (key == "alignment-path") {
+ m_alignmentsFile = value;
+ } else {
+ return DecodeFeature::OverrideParameter(key, value);
}
return true;