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
path: root/moses
diff options
context:
space:
mode:
Diffstat (limited to 'moses')
-rw-r--r--moses/ChartCellLabel.h4
-rw-r--r--moses/ChartManager.h4
-rw-r--r--moses/ChartTranslationOptions.h4
-rw-r--r--moses/DecodeFeature.cpp31
-rw-r--r--moses/DecodeGraph.h8
-rw-r--r--moses/FF/DistortionScoreProducer.h4
-rw-r--r--moses/FF/FeatureFunction.cpp53
-rw-r--r--moses/FF/FeatureFunction.h20
-rw-r--r--moses/FF/PhrasePairFeature.cpp5
-rw-r--r--moses/FF/PhrasePairFeature.h1
-rw-r--r--moses/FF/SourceWordDeletionFeature.cpp49
-rw-r--r--moses/FF/SourceWordDeletionFeature.h5
-rw-r--r--moses/FF/StatelessFeatureFunction.h8
-rw-r--r--moses/FF/TargetBigramFeature.cpp41
-rw-r--r--moses/FF/TargetBigramFeature.h4
-rw-r--r--moses/FF/TargetNgramFeature.cpp28
-rw-r--r--moses/FF/TargetNgramFeature.h1
-rw-r--r--moses/FF/TargetWordInsertionFeature.cpp28
-rw-r--r--moses/FF/TargetWordInsertionFeature.h1
-rw-r--r--moses/FF/WordTranslationFeature.cpp60
-rw-r--r--moses/FF/WordTranslationFeature.h1
-rw-r--r--moses/FactorCollection.h4
-rw-r--r--moses/LM/Implementation.h4
-rw-r--r--moses/LM/MultiFactor.h4
-rw-r--r--moses/LM/ORLM.h4
-rw-r--r--moses/LM/ParallelBackoff.cpp4
-rw-r--r--moses/LM/Rand.cpp4
-rw-r--r--moses/LVoc.h2
-rw-r--r--moses/PDTAimp.h41
-rw-r--r--moses/RuleCubeItem.h8
-rw-r--r--moses/ScoreComponentCollection.h4
-rw-r--r--moses/ScoreComponentCollectionTest.cpp4
-rw-r--r--moses/StaticData.cpp22
-rw-r--r--moses/StaticData.h4
-rw-r--r--moses/TranslationModel/BilingualDynSuffixArray.h8
-rw-r--r--moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp12
-rw-r--r--moses/TranslationModel/CYKPlusParser/DotChartInMemory.h4
-rw-r--r--moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp2
-rw-r--r--moses/TranslationModel/CompactPT/MmapAllocator.h16
-rw-r--r--moses/TranslationModel/CompactPT/PhraseDecoder.cpp6
-rw-r--r--moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp2
-rw-r--r--moses/TranslationModel/CompactPT/PhraseTableCreator.cpp8
-rw-r--r--moses/TranslationModel/CompactPT/PhraseTableCreator.h2
-rw-r--r--moses/TranslationModel/CompactPT/TargetPhraseCollectionCache.h4
-rw-r--r--moses/TranslationModel/DynSAInclude/onlineRLM.h2
-rw-r--r--moses/TranslationModel/PhraseDictionary.cpp39
-rw-r--r--moses/TranslationModel/PhraseDictionary.h12
-rw-r--r--moses/TranslationModel/PhraseDictionaryDynSuffixArray.cpp30
-rw-r--r--moses/TranslationModel/PhraseDictionaryDynSuffixArray.h3
-rw-r--r--moses/TranslationModel/PhraseDictionaryMemory.h8
-rw-r--r--moses/TranslationModel/PhraseDictionaryMultiModel.cpp59
-rw-r--r--moses/TranslationModel/PhraseDictionaryMultiModel.h1
-rw-r--r--moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp102
-rw-r--r--moses/TranslationModel/PhraseDictionaryNodeMemory.h4
-rw-r--r--moses/TranslationModel/PhraseDictionaryTree.cpp4
-rw-r--r--moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp5
-rw-r--r--moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h5
-rw-r--r--moses/TranslationModel/RuleTable/Trie.h4
-rw-r--r--moses/TranslationModel/RuleTable/UTrie.h4
-rw-r--r--moses/TranslationModel/fuzzy-match/Match.h4
-rw-r--r--moses/TranslationModel/fuzzy-match/SentenceAlignment.h4
-rw-r--r--moses/TreeInput.h8
-rw-r--r--moses/TypeDef.h52
-rw-r--r--moses/WordsRange.h4
-rw-r--r--moses/XmlOption.h4
65 files changed, 475 insertions, 416 deletions
diff --git a/moses/ChartCellLabel.h b/moses/ChartCellLabel.h
index ad6e3565d..e00461249 100644
--- a/moses/ChartCellLabel.h
+++ b/moses/ChartCellLabel.h
@@ -52,8 +52,8 @@ public:
Stack stack=Stack())
: m_coverage(coverage)
, m_label(label)
- , m_stack(stack)
- {}
+ , m_stack(stack) {
+ }
const WordsRange &GetCoverage() const {
return m_coverage;
diff --git a/moses/ChartManager.h b/moses/ChartManager.h
index 736986e05..31f3ead07 100644
--- a/moses/ChartManager.h
+++ b/moses/ChartManager.h
@@ -95,8 +95,8 @@ public:
* to be called after processing a sentence (which may consist of more than just calling ProcessSentence() )
* currently an empty function
*/
- void CalcDecoderStatistics() const
- { }
+ void CalcDecoderStatistics() const {
+ }
void ResetSentenceStats(const InputType& source) {
m_sentenceStats = std::auto_ptr<SentenceStats>(new SentenceStats(source));
diff --git a/moses/ChartTranslationOptions.h b/moses/ChartTranslationOptions.h
index 459c91659..785f6aad7 100644
--- a/moses/ChartTranslationOptions.h
+++ b/moses/ChartTranslationOptions.h
@@ -49,8 +49,8 @@ public:
: m_stackVec(stackVec)
, m_targetPhraseCollection(&targetPhraseColl)
, m_wordsRange(&wordsRange)
- , m_estimateOfBestScore(score)
- {}
+ , m_estimateOfBestScore(score) {
+ }
~ChartTranslationOptions() {}
diff --git a/moses/DecodeFeature.cpp b/moses/DecodeFeature.cpp
index 37af49e3f..c5daa58e8 100644
--- a/moses/DecodeFeature.cpp
+++ b/moses/DecodeFeature.cpp
@@ -36,13 +36,12 @@ DecodeFeature::DecodeFeature( const std::string& description
VERBOSE(2,"DecodeFeature:" << std::endl);
size_t ind = 0;
while (ind < m_args.size()) {
- vector<string> &args = m_args[ind];
+ vector<string> &args = m_args[ind];
bool consumed = OverrideParameter(args[0], args[1]);
if (consumed) {
- m_args.erase(m_args.begin() + ind);
- }
- else {
- ++ind;
+ m_args.erase(m_args.begin() + ind);
+ } else {
+ ++ind;
}
}
}
@@ -70,19 +69,17 @@ DecodeFeature::DecodeFeature(const std::string& description
bool DecodeFeature::OverrideParameter(const std::string& key, const std::string& value)
{
- if (key == "input-factor") {
- m_input =Tokenize<FactorType>(value, ",");
- m_inputFactors = FactorMask(m_input);
- }
- else if (key == "output-factor") {
- m_output =Tokenize<FactorType>(value, ",");
- m_outputFactors = FactorMask(m_output);
- }
- else {
- return StatelessFeatureFunction::OverrideParameter(key, value);
- }
+ if (key == "input-factor") {
+ m_input =Tokenize<FactorType>(value, ",");
+ m_inputFactors = FactorMask(m_input);
+ } else if (key == "output-factor") {
+ m_output =Tokenize<FactorType>(value, ",");
+ m_outputFactors = FactorMask(m_output);
+ } else {
+ return StatelessFeatureFunction::OverrideParameter(key, value);
+ }
- return true;
+ return true;
}
diff --git a/moses/DecodeGraph.h b/moses/DecodeGraph.h
index ad5eb8ace..4225e4a84 100644
--- a/moses/DecodeGraph.h
+++ b/moses/DecodeGraph.h
@@ -47,14 +47,14 @@ public:
**/
DecodeGraph(size_t position)
: m_position(position)
- , m_maxChartSpan(NOT_FOUND)
- {}
+ , m_maxChartSpan(NOT_FOUND) {
+ }
// for chart decoding
DecodeGraph(size_t position, size_t maxChartSpan)
: m_position(position)
- , m_maxChartSpan(maxChartSpan)
- {}
+ , m_maxChartSpan(maxChartSpan) {
+ }
//! iterators
typedef std::list<const DecodeStep*>::iterator iterator;
diff --git a/moses/FF/DistortionScoreProducer.h b/moses/FF/DistortionScoreProducer.h
index 305326bd7..a51f3bdb8 100644
--- a/moses/FF/DistortionScoreProducer.h
+++ b/moses/FF/DistortionScoreProducer.h
@@ -18,8 +18,8 @@ class DistortionScoreProducer : public StatefulFeatureFunction
{
public:
DistortionScoreProducer(const std::string &line)
- : StatefulFeatureFunction("Distortion", 1, line)
- {}
+ : StatefulFeatureFunction("Distortion", 1, line) {
+ }
bool IsUseable(const FactorMask &mask) const {
return true;
diff --git a/moses/FF/FeatureFunction.cpp b/moses/FF/FeatureFunction.cpp
index 092caea32..ae5a38983 100644
--- a/moses/FF/FeatureFunction.cpp
+++ b/moses/FF/FeatureFunction.cpp
@@ -22,10 +22,10 @@ std::vector<const StatefulFeatureFunction*> StatefulFeatureFunction::m_stateful
FeatureFunction &FeatureFunction::FindFeatureFunction(const std::string& name)
{
for (size_t i = 0; i < m_producers.size(); ++i) {
- FeatureFunction &ff = *m_producers[i];
- if (ff.GetScoreProducerDescription() == name) {
- return ff;
- }
+ FeatureFunction &ff = *m_producers[i];
+ if (ff.GetScoreProducerDescription() == name) {
+ return ff;
+ }
}
throw "Unknown feature " + name;
@@ -50,25 +50,24 @@ void FeatureFunction::Initialize(const std::string& description, const std::stri
size_t ind = 0;
while (ind < m_args.size()) {
- vector<string> &args = m_args[ind];
+ vector<string> &args = m_args[ind];
bool consumed = OverrideParameter(args[0], args[1]);
if (consumed) {
- m_args.erase(m_args.begin() + ind);
- }
- else {
- ++ind;
+ m_args.erase(m_args.begin() + ind);
+ } else {
+ ++ind;
}
}
if (m_description == "") {
- size_t index = description_counts.count(description);
+ size_t index = description_counts.count(description);
- ostringstream dstream;
- dstream << description;
- dstream << index;
+ ostringstream dstream;
+ dstream << description;
+ dstream << index;
- description_counts.insert(description);
- m_description = dstream.str();
+ description_counts.insert(description);
+ m_description = dstream.str();
}
ScoreComponentCollection::RegisterScoreProducer(this);
@@ -93,18 +92,18 @@ void FeatureFunction::ParseLine(const std::string& description, const std::strin
bool FeatureFunction::OverrideParameter(const std::string& key, const std::string& value)
{
- if (key == "num-features") {
- m_numScoreComponents = Scan<size_t>(value);
- } else if (key == "name") {
- m_description = value;
- } else if (key == "tuneable") {
- m_tuneable = Scan<bool>(value);
- } else {
- //UTIL_THROW(util::Exception, "unknown key" << key);
- return false;
- }
-
- return true;
+ if (key == "num-features") {
+ m_numScoreComponents = Scan<size_t>(value);
+ } else if (key == "name") {
+ m_description = value;
+ } else if (key == "tuneable") {
+ m_tuneable = Scan<bool>(value);
+ } else {
+ //UTIL_THROW(util::Exception, "unknown key" << key);
+ return false;
+ }
+
+ return true;
}
}
diff --git a/moses/FF/FeatureFunction.h b/moses/FF/FeatureFunction.h
index 71688b436..8b95718e2 100644
--- a/moses/FF/FeatureFunction.h
+++ b/moses/FF/FeatureFunction.h
@@ -55,8 +55,8 @@ public:
virtual ~FeatureFunction();
//! override to load model files
- virtual void Load()
- {}
+ virtual void Load() {
+ }
static void ResetDescriptionCounts() {
description_counts.clear();
@@ -80,12 +80,12 @@ public:
}
//! Called before search and collecting of translation options
- virtual void InitializeForInput(InputType const& source)
- {}
+ virtual void InitializeForInput(InputType const& source) {
+ }
// clean up temporary memory, called after processing each sentence
- virtual void CleanUpAfterSentenceProcessing(const InputType& source)
- {}
+ virtual void CleanUpAfterSentenceProcessing(const InputType& source) {
+ }
const std::string &GetArgLine() const {
return m_argLine;
@@ -99,12 +99,12 @@ public:
virtual void Evaluate(const Phrase &source
, const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedFutureScore) const
- {}
+ , ScoreComponentCollection &estimatedFutureScore) const {
+ }
virtual void Evaluate(const InputType &source
- , ScoreComponentCollection &scoreBreakdown) const
- {}
+ , ScoreComponentCollection &scoreBreakdown) const {
+ }
virtual bool OverrideParameter(const std::string& key, const std::string& value);
};
diff --git a/moses/FF/PhrasePairFeature.cpp b/moses/FF/PhrasePairFeature.cpp
index 9cd50c08b..e3f7e5d9a 100644
--- a/moses/FF/PhrasePairFeature.cpp
+++ b/moses/FF/PhrasePairFeature.cpp
@@ -45,6 +45,11 @@ PhrasePairFeature::PhrasePairFeature(const std::string &line)
Load(filePathSource);
}
+bool PhrasePairFeature::OverrideParameter(const std::string& key, const std::string& value)
+{
+
+}
+
bool PhrasePairFeature::Load(const std::string &filePathSource/*, const std::string &filePathTarget*/)
{
if (m_domainTrigger) {
diff --git a/moses/FF/PhrasePairFeature.h b/moses/FF/PhrasePairFeature.h
index 84d94f09b..bd3ab733a 100644
--- a/moses/FF/PhrasePairFeature.h
+++ b/moses/FF/PhrasePairFeature.h
@@ -45,6 +45,7 @@ public:
}
bool Load(const std::string &filePathSource/*, const std::string &filePathTarget*/);
+ bool OverrideParameter(const std::string& key, const std::string& value);
};
diff --git a/moses/FF/SourceWordDeletionFeature.cpp b/moses/FF/SourceWordDeletionFeature.cpp
index 693812105..c7055a79f 100644
--- a/moses/FF/SourceWordDeletionFeature.cpp
+++ b/moses/FF/SourceWordDeletionFeature.cpp
@@ -10,6 +10,7 @@
#include "moses/Util.h"
#include "util/string_piece_hash.hh"
+#include "util/exception.hh"
namespace Moses
{
@@ -22,37 +23,42 @@ SourceWordDeletionFeature::SourceWordDeletionFeature(const std::string &line)
{
std::cerr << "Initializing source word deletion feature.." << std::endl;
- string filename;
- for (size_t i = 0; i < m_args.size(); ++i) {
- const vector<string> &args = m_args[i];
-
- if (args[0] == "factor") {
- m_factorType = Scan<FactorType>(args[1]);
- } else if (args[0] == "path") {
- filename = 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;
}
}
- // load word list for restricted feature set
- if (filename != "") {
- cerr << "loading source word deletion word list from " << filename << endl;
- if (!Load(filename)) {
- UserMessage::Add("Unable to load word list for source word deletion feature from file " + filename);
- //return false;
- }
+}
+
+bool SourceWordDeletionFeature::OverrideParameter(const std::string& key, const std::string& value)
+{
+ if (key == "factor") {
+ m_factorType = Scan<FactorType>(value);
+ } else if (key == "path") {
+ m_filename = value;
+ } else {
+ StatelessFeatureFunction::OverrideParameter(key, value);
}
+
}
-bool SourceWordDeletionFeature::Load(const std::string &filePath)
+void SourceWordDeletionFeature::Load()
{
- ifstream inFile(filePath.c_str());
- if (!inFile) {
- cerr << "could not open file " << filePath << endl;
- return false;
+ if (m_filename == "") {
+ return;
}
+ cerr << "loading source word deletion word list from " << m_filename << endl;
+
+ ifstream inFile(m_filename.c_str());
+ UTIL_THROW_IF(!inFile, util::Exception, "Can't open file " << m_filename);
+
std::string line;
while (getline(inFile, line)) {
m_vocab.insert(line);
@@ -61,7 +67,6 @@ bool SourceWordDeletionFeature::Load(const std::string &filePath)
inFile.close();
m_unrestricted = false;
- return true;
}
void SourceWordDeletionFeature::Evaluate(const Phrase &source
diff --git a/moses/FF/SourceWordDeletionFeature.h b/moses/FF/SourceWordDeletionFeature.h
index 0c4faa5e1..3784ca518 100644
--- a/moses/FF/SourceWordDeletionFeature.h
+++ b/moses/FF/SourceWordDeletionFeature.h
@@ -19,11 +19,12 @@ private:
boost::unordered_set<std::string> m_vocab;
FactorType m_factorType;
bool m_unrestricted;
+ std::string m_filename;
public:
SourceWordDeletionFeature(const std::string &line);
- bool Load(const std::string &filePath);
+ void Load();
bool IsUseable(const FactorMask &mask) const {
return true;
@@ -38,6 +39,8 @@ public:
const TargetPhrase& targetPhrase,
ScoreComponentCollection* accumulator,
const AlignmentInfo &alignmentInfo) const;
+ bool OverrideParameter(const std::string& key, const std::string& value);
+
};
}
diff --git a/moses/FF/StatelessFeatureFunction.h b/moses/FF/StatelessFeatureFunction.h
index 3f120a1de..1e2c6d450 100644
--- a/moses/FF/StatelessFeatureFunction.h
+++ b/moses/FF/StatelessFeatureFunction.h
@@ -24,15 +24,15 @@ public:
* This should be implemented for features that apply to phrase-based models.
**/
virtual void Evaluate(const PhraseBasedFeatureContext& context,
- ScoreComponentCollection* accumulator) const
- {}
+ ScoreComponentCollection* accumulator) const {
+ }
/**
* Same for chart-based features.
**/
virtual void EvaluateChart(const ChartBasedFeatureContext& context,
- ScoreComponentCollection* accumulator) const
- {}
+ ScoreComponentCollection* accumulator) const {
+ }
virtual bool IsStateless() const {
return true;
diff --git a/moses/FF/TargetBigramFeature.cpp b/moses/FF/TargetBigramFeature.cpp
index 629c65b19..d04b4af2b 100644
--- a/moses/FF/TargetBigramFeature.cpp
+++ b/moses/FF/TargetBigramFeature.cpp
@@ -4,6 +4,7 @@
#include "moses/Hypothesis.h"
#include "moses/ScoreComponentCollection.h"
#include "util/string_piece_hash.hh"
+#include "util/exception.hh"
using namespace std;
@@ -21,30 +22,43 @@ TargetBigramFeature::TargetBigramFeature(const std::string &line)
{
std::cerr << "Initializing target bigram feature.." << std::endl;
- vector<string> tokens = Tokenize(line);
- //CHECK(tokens[0] == m_description);
-
- // set factor
- m_factorType = Scan<FactorType>(tokens[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 {
+ ++ind;
+ }
+ }
FactorCollection& factorCollection = FactorCollection::Instance();
const Factor* bosFactor =
factorCollection.AddFactor(Output,m_factorType,BOS_);
m_bos.SetFactor(m_factorType,bosFactor);
- const string &filePath = tokens[2];
- Load(filePath);
-
}
-bool TargetBigramFeature::Load(const std::string &filePath)
+bool TargetBigramFeature::OverrideParameter(const std::string& key, const std::string& value)
{
- if (filePath == "*") return true; //allow all
- ifstream inFile(filePath.c_str());
- if (!inFile) {
- return false;
+ if (key == "factor") {
+ m_factorType = Scan<FactorType>(value);
+ } else if (key == "path") {
+ m_filePath = value;
+ } else {
+ StatefulFeatureFunction::OverrideParameter(key, value);
}
+}
+
+void TargetBigramFeature::Load()
+{
+ if (m_filePath == "*")
+ return ; //allow all
+ ifstream inFile(m_filePath.c_str());
+ UTIL_THROW_IF(!inFile, util::Exception, "Can't open file " << m_filePath);
+
std::string line;
m_vocab.insert(BOS_);
m_vocab.insert(BOS_);
@@ -53,7 +67,6 @@ bool TargetBigramFeature::Load(const std::string &filePath)
}
inFile.close();
- return true;
}
diff --git a/moses/FF/TargetBigramFeature.h b/moses/FF/TargetBigramFeature.h
index d90c6276a..5e36a542f 100644
--- a/moses/FF/TargetBigramFeature.h
+++ b/moses/FF/TargetBigramFeature.h
@@ -33,7 +33,7 @@ class TargetBigramFeature : public StatefulFeatureFunction
public:
TargetBigramFeature(const std::string &line);
- bool Load(const std::string &filePath);
+ void Load();
bool IsUseable(const FactorMask &mask) const;
@@ -47,10 +47,12 @@ public:
ScoreComponentCollection* ) const {
abort();
}
+ bool OverrideParameter(const std::string& key, const std::string& value);
private:
FactorType m_factorType;
Word m_bos;
+ std::string m_filePath;
boost::unordered_set<std::string> m_vocab;
};
diff --git a/moses/FF/TargetNgramFeature.cpp b/moses/FF/TargetNgramFeature.cpp
index f9970b025..d6ef6004a 100644
--- a/moses/FF/TargetNgramFeature.cpp
+++ b/moses/FF/TargetNgramFeature.cpp
@@ -42,13 +42,29 @@ TargetNgramFeature::TargetNgramFeature(const std::string &line)
{
std::cerr << "Initializing target ngram feature.." << std::endl;
- vector<string> tokens = Tokenize(line);
- //CHECK(tokens[0] == m_description);
+ 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 {
+ ++ind;
+ }
+ }
+}
- CHECK(tokens.size() == 4);
- m_factorType = Scan<FactorType>(tokens[1]);
- m_n = Scan<size_t>(tokens[2]);
- m_lower_ngrams = Scan<bool>(tokens[3]);
+bool TargetNgramFeature::OverrideParameter(const std::string& key, const std::string& value)
+{
+ if (key == "factor") {
+ m_factorType = Scan<FactorType>(value);
+ } else if (key == "n") {
+ m_n = Scan<size_t>(value);
+ } else if (key == "lower-ngrams") {
+ m_lower_ngrams = Scan<bool>(value);
+ } else {
+ StatefulFeatureFunction::OverrideParameter(key, value);
+ }
}
diff --git a/moses/FF/TargetNgramFeature.h b/moses/FF/TargetNgramFeature.h
index c15f54e49..e886c4520 100644
--- a/moses/FF/TargetNgramFeature.h
+++ b/moses/FF/TargetNgramFeature.h
@@ -191,6 +191,7 @@ public:
virtual FFState* EvaluateChart(const ChartHypothesis& cur_hypo, int featureId,
ScoreComponentCollection* accumulator) const;
+ bool OverrideParameter(const std::string& key, const std::string& value);
private:
FactorType m_factorType;
diff --git a/moses/FF/TargetWordInsertionFeature.cpp b/moses/FF/TargetWordInsertionFeature.cpp
index fd3aa321a..40fd63afa 100644
--- a/moses/FF/TargetWordInsertionFeature.cpp
+++ b/moses/FF/TargetWordInsertionFeature.cpp
@@ -20,18 +20,28 @@ TargetWordInsertionFeature::TargetWordInsertionFeature(const std::string &line)
m_unrestricted(true)
{
std::cerr << "Initializing target word insertion feature.." << std::endl;
-
- for (size_t i = 0; i < m_args.size(); ++i) {
- const vector<string> &args = m_args[i];
-
- if (args[0] == "factor") {
- m_factorType = Scan<FactorType>(args[1]);
- } else if (args[0] == "path") {
- m_filename = 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;
}
}
+
+}
+
+bool TargetWordInsertionFeature::OverrideParameter(const std::string& key, const std::string& value)
+{
+ if (key == "factor") {
+ m_factorType = Scan<FactorType>(value);
+ } else if (key == "path") {
+ m_filename = value;
+ } else {
+ StatelessFeatureFunction::OverrideParameter(key, value);
+ }
}
void TargetWordInsertionFeature::Load()
diff --git a/moses/FF/TargetWordInsertionFeature.h b/moses/FF/TargetWordInsertionFeature.h
index 4cfb6037b..5479448a2 100644
--- a/moses/FF/TargetWordInsertionFeature.h
+++ b/moses/FF/TargetWordInsertionFeature.h
@@ -37,6 +37,7 @@ public:
const TargetPhrase& targetPhrase,
ScoreComponentCollection* accumulator,
const AlignmentInfo &alignmentInfo) const;
+ bool OverrideParameter(const std::string& key, const std::string& value);
};
diff --git a/moses/FF/WordTranslationFeature.cpp b/moses/FF/WordTranslationFeature.cpp
index b353348c8..7a1a92f96 100644
--- a/moses/FF/WordTranslationFeature.cpp
+++ b/moses/FF/WordTranslationFeature.cpp
@@ -27,33 +27,14 @@ WordTranslationFeature::WordTranslationFeature(const std::string &line)
{
std::cerr << "Initializing word translation feature.. " << endl;
- string texttype;
-
- for (size_t i = 0; i < m_args.size(); ++i) {
- const vector<string> &args = m_args[i];
-
- if (args[0] == "input-factor") {
- m_factorTypeSource = Scan<FactorType>(args[1]);
- } else if (args[0] == "output-factor") {
- m_factorTypeTarget = Scan<FactorType>(args[1]);
- } else if (args[0] == "simple") {
- m_simple = Scan<bool>(args[1]);
- } else if (args[0] == "source-context") {
- m_sourceContext = Scan<bool>(args[1]);
- } else if (args[0] == "target-context") {
- m_targetContext = Scan<bool>(args[1]);
- } else if (args[0] == "ignore-punctuation") {
- m_ignorePunctuation = Scan<bool>(args[1]);
- } else if (args[0] == "domain-trigger") {
- m_domainTrigger = Scan<bool>(args[1]);
- } else if (args[0] == "texttype") {
- texttype = args[1];
- } else if (args[0] == "source-path") {
- m_filePathSource = args[1];
- } else if (args[0] == "target-path") {
- m_filePathTarget = 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;
}
}
@@ -89,6 +70,33 @@ WordTranslationFeature::WordTranslationFeature(const std::string &line)
}
+bool WordTranslationFeature::OverrideParameter(const std::string& key, const std::string& value)
+{
+ if (key == "input-factor") {
+ m_factorTypeSource = Scan<FactorType>(value);
+ } else if (key == "output-factor") {
+ m_factorTypeTarget = Scan<FactorType>(value);
+ } else if (key == "simple") {
+ m_simple = Scan<bool>(value);
+ } else if (key == "source-context") {
+ m_sourceContext = Scan<bool>(value);
+ } else if (key == "target-context") {
+ m_targetContext = Scan<bool>(value);
+ } else if (key == "ignore-punctuation") {
+ m_ignorePunctuation = Scan<bool>(value);
+ } else if (key == "domain-trigger") {
+ m_domainTrigger = Scan<bool>(value);
+ } else if (key == "texttype") {
+ //texttype = value; TODO not used
+ } else if (key == "source-path") {
+ m_filePathSource = value;
+ } else if (key == "target-path") {
+ m_filePathTarget = value;
+ } else {
+ StatelessFeatureFunction::OverrideParameter(key, value);
+ }
+}
+
void WordTranslationFeature::Load()
{
// load word list for restricted feature set
diff --git a/moses/FF/WordTranslationFeature.h b/moses/FF/WordTranslationFeature.h
index 1905f7b9f..d99afe715 100644
--- a/moses/FF/WordTranslationFeature.h
+++ b/moses/FF/WordTranslationFeature.h
@@ -52,6 +52,7 @@ public:
void EvaluateChart(const ChartBasedFeatureContext& context,
ScoreComponentCollection* accumulator) const;
+ bool OverrideParameter(const std::string& key, const std::string& value);
};
}
diff --git a/moses/FactorCollection.h b/moses/FactorCollection.h
index 8c3db5da9..3968b4102 100644
--- a/moses/FactorCollection.h
+++ b/moses/FactorCollection.h
@@ -87,8 +87,8 @@ class FactorCollection
//! constructor. only the 1 static variable can be created
FactorCollection()
- :m_factorId(0)
- {}
+ :m_factorId(0) {
+ }
public:
static FactorCollection& Instance() {
diff --git a/moses/LM/Implementation.h b/moses/LM/Implementation.h
index cc78a7823..750fff013 100644
--- a/moses/LM/Implementation.h
+++ b/moses/LM/Implementation.h
@@ -62,8 +62,8 @@ protected:
//! Usually <s> and </s>
LanguageModelImplementation(const std::string& description, const std::string &line)
- :LanguageModel(description, line)
- {}
+ :LanguageModel(description, line) {
+ }
public:
virtual ~LanguageModelImplementation() {}
diff --git a/moses/LM/MultiFactor.h b/moses/LM/MultiFactor.h
index 1edd3920c..619ad94f3 100644
--- a/moses/LM/MultiFactor.h
+++ b/moses/LM/MultiFactor.h
@@ -42,8 +42,8 @@ protected:
FactorMask m_factorTypes;
LanguageModelMultiFactor(const std::string& description, const std::string &line)
- :LanguageModelImplementation(description, line)
- {}
+ :LanguageModelImplementation(description, line) {
+ }
public:
virtual bool Load(const std::string &filePath
diff --git a/moses/LM/ORLM.h b/moses/LM/ORLM.h
index d7a8b5d35..4443b4732 100644
--- a/moses/LM/ORLM.h
+++ b/moses/LM/ORLM.h
@@ -23,8 +23,8 @@ public:
typedef count_t T; // type for ORLM filter
LanguageModelORLM(const std::string &line)
:LanguageModelSingleFactor("ORLM", line)
- ,m_lm(0)
- {}
+ ,m_lm(0) {
+ }
bool Load(const std::string &filePath, FactorType factorType, size_t nGramOrder);
virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = NULL) const;
~LanguageModelORLM() {
diff --git a/moses/LM/ParallelBackoff.cpp b/moses/LM/ParallelBackoff.cpp
index 0b996de2b..e4effdf47 100644
--- a/moses/LM/ParallelBackoff.cpp
+++ b/moses/LM/ParallelBackoff.cpp
@@ -70,8 +70,8 @@ private:
public:
LanguageModelParallelBackoff(const std::string &line)
- :LanguageModelMultiFactor("ParallelBackoffLM", line)
- {}
+ :LanguageModelMultiFactor("ParallelBackoffLM", line) {
+ }
~LanguageModelParallelBackoff();
diff --git a/moses/LM/Rand.cpp b/moses/LM/Rand.cpp
index 5e31029d5..f2516fde7 100644
--- a/moses/LM/Rand.cpp
+++ b/moses/LM/Rand.cpp
@@ -46,8 +46,8 @@ class LanguageModelRandLM : public LanguageModelSingleFactor
public:
LanguageModelRandLM(const std::string &line)
:LanguageModelSingleFactor("RandLM", line)
- , m_lm(0)
- {}
+ , m_lm(0) {
+ }
bool Load(const std::string &filePath, FactorType factorType, size_t nGramOrder);
virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = NULL) const;
~LanguageModelRandLM() {
diff --git a/moses/LVoc.h b/moses/LVoc.h
index 485e3f481..5f5423832 100644
--- a/moses/LVoc.h
+++ b/moses/LVoc.h
@@ -38,7 +38,7 @@ public:
}
LabelId add(const Key& k) {
std::pair<typename M::iterator,bool> p
- =m.insert(std::make_pair(k,data.size()));
+ =m.insert(std::make_pair(k,data.size()));
if(p.second) data.push_back(k);
CHECK(static_cast<size_t>(p.first->second)<data.size());
return p.first->second;
diff --git a/moses/PDTAimp.h b/moses/PDTAimp.h
index c30ab551b..6d1d1cd0c 100644
--- a/moses/PDTAimp.h
+++ b/moses/PDTAimp.h
@@ -40,18 +40,17 @@ protected:
m_obj(p),
useCache(1),
totalE(0),
- distinctE(0)
- {
+ distinctE(0) {
m_numInputScores = 0;
- const StaticData &staticData = StaticData::Instance();
- m_inputFeature = staticData.GetInputFeature();
-
- if (m_inputFeature) {
- const PhraseDictionary *firstPt = staticData.GetPhraseDictionaries()[0];
- if (firstPt == m_obj) {
- m_numInputScores = m_inputFeature->GetNumScoreComponents();
- }
- }
+ const StaticData &staticData = StaticData::Instance();
+ m_inputFeature = staticData.GetInputFeature();
+
+ if (m_inputFeature) {
+ const PhraseDictionary *firstPt = staticData.GetPhraseDictionaries()[0];
+ if (firstPt == m_obj) {
+ m_numInputScores = m_inputFeature->GetNumScoreComponents();
+ }
+ }
}
public:
@@ -179,7 +178,7 @@ public:
//sparse features.
//These are already in log-space
for (size_t j = 0; j < cands[i].fnames.size(); ++j) {
- targetPhrase.GetScoreBreakdown().Assign(m_obj, *cands[i].fnames[j], cands[i].fvalues[j]);
+ targetPhrase.GetScoreBreakdown().Assign(m_obj, *cands[i].fnames[j], cands[i].fvalues[j]);
}
CreateTargetPhrase(targetPhrase,factorStrings,scoreVector, Scores(0), &wacands[i], &src);
@@ -294,7 +293,7 @@ public:
}
if (m_numInputScores) {
- targetPhrase.GetScoreBreakdown().Assign(m_inputFeature, inputVector);
+ targetPhrase.GetScoreBreakdown().Assign(m_inputFeature, inputVector);
}
targetPhrase.GetScoreBreakdown().Assign(m_obj, transVector);
@@ -452,9 +451,9 @@ public:
//put in phrase table scores, logging as we insert
std::transform(tcands[i].scores.begin()
- ,tcands[i].scores.end()
- ,transcores.begin()
- ,TransformScore);
+ ,tcands[i].scores.end()
+ ,transcores.begin()
+ ,TransformScore);
//tally up
@@ -514,11 +513,11 @@ public:
TScores const & scores=j->second;
TargetPhrase targetPhrase;
CreateTargetPhrase(targetPhrase
- , j ->first
- , scores.transScore
- , scores.inputScores
- , NULL
- , scores.src);
+ , j ->first
+ , scores.transScore
+ , scores.inputScores
+ , NULL
+ , scores.src);
costs.push_back(std::make_pair(-targetPhrase.GetFutureScore(),tCands.size()));
tCands.push_back(targetPhrase);
//std::cerr << i->first.first << "-" << i->first.second << ": " << targetPhrase << std::endl;
diff --git a/moses/RuleCubeItem.h b/moses/RuleCubeItem.h
index 75669598b..fdc84509a 100644
--- a/moses/RuleCubeItem.h
+++ b/moses/RuleCubeItem.h
@@ -43,8 +43,8 @@ public:
TranslationDimension(std::size_t pos,
const std::vector<TargetPhrase*> &orderedTargetPhrases)
: m_pos(pos)
- , m_orderedTargetPhrases(&orderedTargetPhrases)
- {}
+ , m_orderedTargetPhrases(&orderedTargetPhrases) {
+ }
std::size_t IncrementPos() {
return m_pos++;
@@ -80,8 +80,8 @@ class HypothesisDimension
public:
HypothesisDimension(std::size_t pos, const HypoList &orderedHypos)
: m_pos(pos)
- , m_orderedHypos(&orderedHypos)
- {}
+ , m_orderedHypos(&orderedHypos) {
+ }
std::size_t IncrementPos() {
return m_pos++;
diff --git a/moses/ScoreComponentCollection.h b/moses/ScoreComponentCollection.h
index 260e8de57..a35cfde71 100644
--- a/moses/ScoreComponentCollection.h
+++ b/moses/ScoreComponentCollection.h
@@ -91,8 +91,8 @@ public:
//! Clone a score collection
ScoreComponentCollection(const ScoreComponentCollection& rhs)
- : m_scores(rhs.m_scores)
- {}
+ : m_scores(rhs.m_scores) {
+ }
ScoreComponentCollection& operator=( const ScoreComponentCollection& rhs ) {
m_scores = rhs.m_scores;
diff --git a/moses/ScoreComponentCollectionTest.cpp b/moses/ScoreComponentCollectionTest.cpp
index 0da083ac6..4b5f20ae2 100644
--- a/moses/ScoreComponentCollectionTest.cpp
+++ b/moses/ScoreComponentCollectionTest.cpp
@@ -38,8 +38,8 @@ public:
virtual void EvaluateChart(const ChartBasedFeatureContext&, ScoreComponentCollection*) const {}
virtual void Evaluate(const TargetPhrase &targetPhrase
, ScoreComponentCollection &scoreBreakdown
- , ScoreComponentCollection &estimatedFutureScore) const
- { }
+ , ScoreComponentCollection &estimatedFutureScore) const {
+ }
};
class MockSingleFeature : public MockStatelessFeatureFunction
diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp
index 19f3a4af6..97d88721f 100644
--- a/moses/StaticData.cpp
+++ b/moses/StaticData.cpp
@@ -938,7 +938,7 @@ const TranslationOptionList* StaticData::FindTransOptListInCache(const DecodeGra
boost::mutex::scoped_lock lock(m_transOptCacheMutex);
#endif
std::map<std::pair<std::pair<size_t, std::string>, Phrase>, std::pair<TranslationOptionList*,clock_t> >::iterator iter
- = m_transOptCache.find(key);
+ = m_transOptCache.find(key);
if (iter == m_transOptCache.end())
return NULL;
iter->second.second = clock(); // update last used time
@@ -1296,19 +1296,19 @@ void StaticData::OverrideFeatures()
{
const PARAM_VEC &params = m_parameter->GetParam("feature-overwrite");
for (size_t i = 0; i < params.size(); ++i) {
- const string &str = params[i];
- vector<string> toks = Tokenize(str);
- CHECK(toks.size() > 1);
+ const string &str = params[i];
+ vector<string> toks = Tokenize(str);
+ CHECK(toks.size() > 1);
- FeatureFunction &ff = FeatureFunction::FindFeatureFunction(toks[0]);
+ FeatureFunction &ff = FeatureFunction::FindFeatureFunction(toks[0]);
- for (size_t j = 1; j < toks.size(); ++j) {
- const string &keyValStr = toks[j];
- vector<string> keyVal = Tokenize(keyValStr, "=");
- CHECK(keyVal.size() == 2);
- ff.OverrideParameter(keyVal[0], keyVal[1]);
+ for (size_t j = 1; j < toks.size(); ++j) {
+ const string &keyValStr = toks[j];
+ vector<string> keyVal = Tokenize(keyValStr, "=");
+ CHECK(keyVal.size() == 2);
+ ff.OverrideParameter(keyVal[0], keyVal[1]);
- }
+ }
}
}
diff --git a/moses/StaticData.h b/moses/StaticData.h
index 20be38687..17afc1790 100644
--- a/moses/StaticData.h
+++ b/moses/StaticData.h
@@ -673,7 +673,7 @@ public:
return false;
}
std::map< std::string, std::set< std::string > >::const_iterator lookupIgnoreFF
- = m_weightSettingIgnoreFF.find( m_currentWeightSetting );
+ = m_weightSettingIgnoreFF.find( m_currentWeightSetting );
if (lookupIgnoreFF == m_weightSettingIgnoreFF.end()) {
return false;
}
@@ -691,7 +691,7 @@ public:
return false;
}
std::map< std::string, std::set< size_t > >::const_iterator lookupIgnoreDP
- = m_weightSettingIgnoreDP.find( m_currentWeightSetting );
+ = m_weightSettingIgnoreDP.find( m_currentWeightSetting );
if (lookupIgnoreDP == m_weightSettingIgnoreDP.end()) {
return false;
}
diff --git a/moses/TranslationModel/BilingualDynSuffixArray.h b/moses/TranslationModel/BilingualDynSuffixArray.h
index 08637d095..7a4d47eea 100644
--- a/moses/TranslationModel/BilingualDynSuffixArray.h
+++ b/moses/TranslationModel/BilingualDynSuffixArray.h
@@ -20,8 +20,8 @@ public:
std::vector<wordID_t> words;
SAPhrase(size_t phraseSize)
- :words(phraseSize)
- {}
+ :words(phraseSize) {
+ }
void SetId(size_t pos, wordID_t id) {
CHECK(pos < words.size());
@@ -43,8 +43,8 @@ public:
, m_endTarget(endTarget)
, m_startSource(startSource)
, m_endSource(endSource)
- , m_sntIndex(sntIndex)
- {}
+ , m_sntIndex(sntIndex) {
+ }
size_t GetTargetSize() const {
return m_endTarget - m_startTarget + 1;
diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
index 5dde99ade..195f6708e 100644
--- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
+++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
@@ -234,12 +234,12 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection(
std::vector<float> weightT = staticData.GetWeights(&m_dictionary);
targetPhraseCollection
- = tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec
- ,m_outputFactorsVec
- ,m_dictionary
- ,weightT
- ,m_filePath
- , m_dbWrapper.GetVocab());
+ = tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec
+ ,m_outputFactorsVec
+ ,m_dictionary
+ ,weightT
+ ,m_filePath
+ , m_dbWrapper.GetVocab());
delete tpcollBerkeleyDb;
m_cache[tpCollFilePos] = targetPhraseCollection;
diff --git a/moses/TranslationModel/CYKPlusParser/DotChartInMemory.h b/moses/TranslationModel/CYKPlusParser/DotChartInMemory.h
index cfd986d7a..83a40d60f 100644
--- a/moses/TranslationModel/CYKPlusParser/DotChartInMemory.h
+++ b/moses/TranslationModel/CYKPlusParser/DotChartInMemory.h
@@ -83,8 +83,8 @@ public:
}
DottedRuleColl(size_t size)
- : m_coll(size)
- {}
+ : m_coll(size) {
+ }
~DottedRuleColl();
diff --git a/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp b/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp
index 655ed01ca..7e60dec7d 100644
--- a/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp
+++ b/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp
@@ -428,7 +428,7 @@ void CompressionTaskReordering::operator()()
while(scoresNum < m_encodedScores.size()) {
std::string scores = m_encodedScores[scoresNum];
std::string compressedScores
- = m_creator.CompressEncodedScores(scores);
+ = m_creator.CompressEncodedScores(scores);
std::string dummy;
PackedItem packedItem(scoresNum, dummy, compressedScores, 0);
diff --git a/moses/TranslationModel/CompactPT/MmapAllocator.h b/moses/TranslationModel/CompactPT/MmapAllocator.h
index 7cd6dd49e..6ff890c88 100644
--- a/moses/TranslationModel/CompactPT/MmapAllocator.h
+++ b/moses/TranslationModel/CompactPT/MmapAllocator.h
@@ -57,26 +57,26 @@ public:
MmapAllocator() throw()
: m_file_ptr(std::tmpfile()), m_file_desc(fileno(m_file_ptr)),
m_page_size(sysconf(_SC_PAGE_SIZE)), m_map_size(0), m_data_ptr(0),
- m_data_offset(0), m_fixed(false), m_count(new size_t(0))
- { }
+ m_data_offset(0), m_fixed(false), m_count(new size_t(0)) {
+ }
MmapAllocator(std::FILE* f_ptr) throw()
: m_file_ptr(f_ptr), m_file_desc(fileno(m_file_ptr)),
m_page_size(sysconf(_SC_PAGE_SIZE)), m_map_size(0), m_data_ptr(0),
- m_data_offset(0), m_fixed(false), m_count(new size_t(0))
- { }
+ m_data_offset(0), m_fixed(false), m_count(new size_t(0)) {
+ }
MmapAllocator(std::FILE* f_ptr, size_t data_offset) throw()
: m_file_ptr(f_ptr), m_file_desc(fileno(m_file_ptr)),
m_page_size(sysconf(_SC_PAGE_SIZE)), m_map_size(0), m_data_ptr(0),
- m_data_offset(data_offset), m_fixed(true), m_count(new size_t(0))
- { }
+ m_data_offset(data_offset), m_fixed(true), m_count(new size_t(0)) {
+ }
MmapAllocator(std::string fileName) throw()
: m_file_ptr(std::fopen(fileName.c_str(), "wb+")), m_file_desc(fileno(m_file_ptr)),
m_page_size(sysconf(_SC_PAGE_SIZE)), m_map_size(0), m_data_ptr(0),
- m_data_offset(0), m_fixed(false), m_count(new size_t(0))
- { }
+ m_data_offset(0), m_fixed(false), m_count(new size_t(0)) {
+ }
MmapAllocator(const MmapAllocator& c) throw()
: m_file_ptr(c.m_file_ptr), m_file_desc(c.m_file_desc),
diff --git a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp
index 085a7337c..a15f301bb 100644
--- a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp
+++ b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp
@@ -61,7 +61,7 @@ PhraseDecoder::~PhraseDecoder()
inline unsigned PhraseDecoder::GetSourceSymbolId(std::string& symbol)
{
boost::unordered_map<std::string, unsigned>::iterator it
- = m_sourceSymbolsMap.find(symbol);
+ = m_sourceSymbolsMap.find(symbol);
if(it != m_sourceSymbolsMap.end())
return it->second;
@@ -200,7 +200,7 @@ TargetPhraseVectorPtr PhraseDecoder::CreateTargetPhraseCollection(const Phrase &
if(m_coding == PREnc) {
std::pair<TargetPhraseVectorPtr, size_t> cachedPhraseColl
- = m_decodingCache.Retrieve(sourcePhrase);
+ = m_decodingCache.Retrieve(sourcePhrase);
// Has been cached and is complete or does not need to be completed
if(cachedPhraseColl.first != NULL && (!topLevel || cachedPhraseColl.second == 0))
@@ -255,7 +255,7 @@ TargetPhraseVectorPtr PhraseDecoder::DecodeCollection(
if(m_coding == REnc) {
for(size_t i = 0; i < sourcePhrase.GetSize(); i++) {
std::string sourceWord
- = sourcePhrase.GetWord(i).GetString(*m_input, false);
+ = sourcePhrase.GetWord(i).GetString(*m_input, false);
unsigned idx = GetSourceSymbolId(sourceWord);
sourceWords.push_back(idx);
}
diff --git a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
index 64cfc24cf..90125ffbf 100644
--- a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
+++ b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp
@@ -106,7 +106,7 @@ PhraseDictionaryCompact::GetTargetPhraseCollection(const Phrase &sourcePhrase) c
// Retrieve target phrase collection from phrase table
TargetPhraseVectorPtr decodedPhraseColl
- = m_phraseDecoder->CreateTargetPhraseCollection(sourcePhrase, true);
+ = m_phraseDecoder->CreateTargetPhraseCollection(sourcePhrase, true);
if(decodedPhraseColl != NULL && decodedPhraseColl->size()) {
TargetPhraseVectorPtr tpv(new TargetPhraseVector(*decodedPhraseColl));
diff --git a/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp b/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp
index fc3b056c6..33dcf3f8b 100644
--- a/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp
+++ b/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp
@@ -426,7 +426,7 @@ void PhraseTableCreator::AddTargetSymbolId(std::string& symbol)
unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol)
{
boost::unordered_map<std::string, unsigned>::iterator it
- = m_sourceSymbolsMap.find(symbol);
+ = m_sourceSymbolsMap.find(symbol);
if(it != m_sourceSymbolsMap.end())
return it->second;
@@ -437,7 +437,7 @@ unsigned PhraseTableCreator::GetSourceSymbolId(std::string& symbol)
unsigned PhraseTableCreator::GetTargetSymbolId(std::string& symbol)
{
boost::unordered_map<std::string, unsigned>::iterator it
- = m_targetSymbolsMap.find(symbol);
+ = m_targetSymbolsMap.find(symbol);
if(it != m_targetSymbolsMap.end())
return it->second;
@@ -451,7 +451,7 @@ unsigned PhraseTableCreator::GetOrAddTargetSymbolId(std::string& symbol)
boost::mutex::scoped_lock lock(m_mutex);
#endif
boost::unordered_map<std::string, unsigned>::iterator it
- = m_targetSymbolsMap.find(symbol);
+ = m_targetSymbolsMap.find(symbol);
if(it != m_targetSymbolsMap.end())
return it->second;
@@ -1200,7 +1200,7 @@ void CompressionTask::operator()()
while(collectionNum < m_encodedCollections.size()) {
std::string collection = m_encodedCollections[collectionNum];
std::string compressedCollection
- = m_creator.CompressEncodedCollection(collection);
+ = m_creator.CompressEncodedCollection(collection);
std::string dummy;
PackedItem packedItem(collectionNum, dummy, compressedCollection, 0);
diff --git a/moses/TranslationModel/CompactPT/PhraseTableCreator.h b/moses/TranslationModel/CompactPT/PhraseTableCreator.h
index fd5fc1581..b92df1697 100644
--- a/moses/TranslationModel/CompactPT/PhraseTableCreator.h
+++ b/moses/TranslationModel/CompactPT/PhraseTableCreator.h
@@ -143,7 +143,7 @@ public:
return data;
else {
typename std::vector<DataType>::iterator it
- = std::lower_bound(m_bestVec.begin(), m_bestVec.end(), data);
+ = std::lower_bound(m_bestVec.begin(), m_bestVec.end(), data);
if(it != m_bestVec.end())
return *it;
else
diff --git a/moses/TranslationModel/CompactPT/TargetPhraseCollectionCache.h b/moses/TranslationModel/CompactPT/TargetPhraseCollectionCache.h
index 3eac0226a..c7f245370 100644
--- a/moses/TranslationModel/CompactPT/TargetPhraseCollectionCache.h
+++ b/moses/TranslationModel/CompactPT/TargetPhraseCollectionCache.h
@@ -75,8 +75,8 @@ public:
typedef CacheMap::const_iterator const_iterator;
TargetPhraseCollectionCache(size_t max = 5000, float tolerance = 0.2)
- : m_max(max), m_tolerance(tolerance)
- {}
+ : m_max(max), m_tolerance(tolerance) {
+ }
iterator Begin() {
return m_phraseCache.begin();
diff --git a/moses/TranslationModel/DynSAInclude/onlineRLM.h b/moses/TranslationModel/DynSAInclude/onlineRLM.h
index 527f1e5d9..6c2a1db22 100644
--- a/moses/TranslationModel/DynSAInclude/onlineRLM.h
+++ b/moses/TranslationModel/DynSAInclude/onlineRLM.h
@@ -338,7 +338,7 @@ template<typename T>
const void* OnlineRLM<T>::getContext(const wordID_t* ngram, int len)
{
int dummy(0);
- float* *addresses = new float*[len]; // only interested in addresses of cache
+ float**addresses = new float*[len]; // only interested in addresses of cache
CHECK(cache_->getCache2(ngram, len, &addresses[0], &dummy) == len);
// return address of cache node
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;
diff --git a/moses/TranslationModel/PhraseDictionary.h b/moses/TranslationModel/PhraseDictionary.h
index 80033ac48..9c49768f4 100644
--- a/moses/TranslationModel/PhraseDictionary.h
+++ b/moses/TranslationModel/PhraseDictionary.h
@@ -56,8 +56,8 @@ class PhraseDictionary : public DecodeFeature
public:
PhraseDictionary(const std::string &description, const std::string &line);
- virtual ~PhraseDictionary()
- {}
+ virtual ~PhraseDictionary() {
+ }
//! table limit number.
size_t GetTableLimit() const {
@@ -70,11 +70,11 @@ public:
virtual const TargetPhraseCollection *GetTargetPhraseCollection(InputType const& src,WordsRange const& range) const;
//! Create entry for translation of source to targetPhrase
- virtual void InitializeForInput(InputType const& source)
- {}
+ virtual void InitializeForInput(InputType const& source) {
+ }
// clean up temporary memory, called after processing each sentence
- virtual void CleanUpAfterSentenceProcessing(const InputType& source)
- {}
+ virtual void CleanUpAfterSentenceProcessing(const InputType& source) {
+ }
//! Create a sentence-specific manager for SCFG rule lookup.
virtual ChartRuleLookupManager *CreateRuleLookupManager(
diff --git a/moses/TranslationModel/PhraseDictionaryDynSuffixArray.cpp b/moses/TranslationModel/PhraseDictionaryDynSuffixArray.cpp
index 299aad6e1..9df0cd69d 100644
--- a/moses/TranslationModel/PhraseDictionaryDynSuffixArray.cpp
+++ b/moses/TranslationModel/PhraseDictionaryDynSuffixArray.cpp
@@ -12,17 +12,14 @@ PhraseDictionaryDynSuffixArray::PhraseDictionaryDynSuffixArray(const std::string
:PhraseDictionary("PhraseDictionaryDynSuffixArray", line)
,m_biSA(new BilingualDynSuffixArray())
{
-
- for (size_t i = 0; i < m_args.size(); ++i) {
- const vector<string> &args = m_args[i];
- if (args[0] == "source") {
- m_source = args[1];
- } else if (args[0] == "target") {
- m_target = args[1];
- } else if (args[0] == "alignment") {
- m_alignments = 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;
}
}
@@ -80,4 +77,17 @@ ChartRuleLookupManager *PhraseDictionaryDynSuffixArray::CreateRuleLookupManager(
throw "Chart decoding not supported by PhraseDictionaryDynSuffixArray";
}
+bool PhraseDictionaryDynSuffixArray::OverrideParameter(const std::string& key, const std::string& value)
+{
+ if (key == "source") {
+ m_source = value;
+ } else if (key == "target") {
+ m_target = value;
+ } else if (key == "alignment") {
+ m_alignments = value;
+ } else {
+ PhraseDictionary::OverrideParameter(key, value);
+ }
+}
+
}// end namepsace
diff --git a/moses/TranslationModel/PhraseDictionaryDynSuffixArray.h b/moses/TranslationModel/PhraseDictionaryDynSuffixArray.h
index 90015fe3b..d08ef2bc2 100644
--- a/moses/TranslationModel/PhraseDictionaryDynSuffixArray.h
+++ b/moses/TranslationModel/PhraseDictionaryDynSuffixArray.h
@@ -25,6 +25,9 @@ public:
void insertSnt(string&, string&, string&);
void deleteSnt(unsigned, unsigned);
ChartRuleLookupManager *CreateRuleLookupManager(const InputType&, const ChartCellCollectionBase&);
+
+ bool OverrideParameter(const std::string& key, const std::string& value);
+
private:
BilingualDynSuffixArray *m_biSA;
std::string m_source, m_target, m_alignments;
diff --git a/moses/TranslationModel/PhraseDictionaryMemory.h b/moses/TranslationModel/PhraseDictionaryMemory.h
index d2a8d0ad3..96e891d98 100644
--- a/moses/TranslationModel/PhraseDictionaryMemory.h
+++ b/moses/TranslationModel/PhraseDictionaryMemory.h
@@ -38,13 +38,13 @@ class PhraseDictionaryMemory : public RuleTableTrie
protected:
PhraseDictionaryMemory(const std::string &description, const std::string &line)
- : RuleTableTrie(description, line)
- {}
+ : RuleTableTrie(description, line) {
+ }
public:
PhraseDictionaryMemory(const std::string &line)
- : RuleTableTrie("PhraseDictionaryMemory", line)
- {}
+ : RuleTableTrie("PhraseDictionaryMemory", line) {
+ }
const PhraseDictionaryNodeMemory &GetRootNode() const {
return m_collection;
diff --git a/moses/TranslationModel/PhraseDictionaryMultiModel.cpp b/moses/TranslationModel/PhraseDictionaryMultiModel.cpp
index 34972078a..fb8457c8f 100644
--- a/moses/TranslationModel/PhraseDictionaryMultiModel.cpp
+++ b/moses/TranslationModel/PhraseDictionaryMultiModel.cpp
@@ -28,22 +28,16 @@ namespace Moses
PhraseDictionaryMultiModel::PhraseDictionaryMultiModel(const std::string &line)
:PhraseDictionary("PhraseDictionaryMultiModel", line)
{
- for (size_t i = 0; i < m_args.size(); ++i) {
- const vector<string> &args = m_args[i];
- if (args[0] == "mode") {
- m_mode =args[1];
- if (m_mode != "interpolate") {
- ostringstream msg;
- msg << "combination mode unknown: " << m_mode;
- throw runtime_error(msg.str());
- }
- } else if (args[0] == "components") {
- m_pdStr = Tokenize(args[1], ",");
- m_numModels = m_pdStr.size();
- } else if (args[0] == "lambda") {
- m_multimodelweights = Tokenize<float>(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 {
+ ++ind;
}
- } // for
+ }
size_t numWeights = m_numScoreComponents;
if (m_mode == "interpolate") {
@@ -55,15 +49,16 @@ PhraseDictionaryMultiModel::PhraseDictionaryMultiModel(const std::string &line)
PhraseDictionaryMultiModel::PhraseDictionaryMultiModel(const std::string &description, const std::string &line)
:PhraseDictionary(description, line)
{
- for (size_t i = 0; i < m_args.size(); ++i) {
- const vector<string> &args = m_args[i];
- if (args[0] == "components") {
- m_pdStr = Tokenize(args[1], ",");
- m_numModels = m_pdStr.size();
- } else if (args[0] == "lambda") {
- m_multimodelweights = Tokenize<float>(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 {
+ ++ind;
}
- } // for
+ }
if (description == "PhraseDictionaryMultiModelCounts") {
CHECK(m_pdStr.size() == m_multimodelweights.size() || m_pdStr.size()*4 == m_multimodelweights.size());
@@ -329,6 +324,24 @@ void PhraseDictionaryMultiModel::CleanUpComponentModels(const InputType &source
}
}
+bool PhraseDictionaryMultiModel::OverrideParameter(const std::string& key, const std::string& value)
+{
+ if (key == "mode") {
+ m_mode = value;
+ if (m_mode != "interpolate") {
+ ostringstream msg;
+ msg << "combination mode unknown: " << m_mode;
+ throw runtime_error(msg.str());
+ }
+ } else if (key == "components") {
+ m_pdStr = Tokenize(value, ",");
+ m_numModels = m_pdStr.size();
+ } else if (key == "lambda") {
+ m_multimodelweights = Tokenize<float>(value, ",");
+ } else {
+ PhraseDictionary::OverrideParameter(key, value);
+ }
+}
#ifdef WITH_DLIB
vector<float> PhraseDictionaryMultiModel::MinimizePerplexity(vector<pair<string, string> > &phrase_pair_vector)
diff --git a/moses/TranslationModel/PhraseDictionaryMultiModel.h b/moses/TranslationModel/PhraseDictionaryMultiModel.h
index eae72dcb1..34d46df75 100644
--- a/moses/TranslationModel/PhraseDictionaryMultiModel.h
+++ b/moses/TranslationModel/PhraseDictionaryMultiModel.h
@@ -80,6 +80,7 @@ public:
/* Don't do anything source specific here as this object is shared between threads.*/
}
ChartRuleLookupManager *CreateRuleLookupManager(const InputType&, const ChartCellCollectionBase&);
+ bool OverrideParameter(const std::string& key, const std::string& value);
protected:
std::string m_mode;
diff --git a/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp b/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp
index 06b53e9c6..0d914e9e8 100644
--- a/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp
+++ b/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp
@@ -68,69 +68,16 @@ PhraseDictionaryMultiModelCounts::PhraseDictionaryMultiModelCounts(const std::st
//m_mode = "interpolate";
//m_combineFunction = LinearInterpolationFromCounts;
- for (size_t i = 0; i < m_args.size(); ++i) {
- const vector<string> &args = m_args[i];
- if (args[0] == "mode") {
- m_mode = args[1];
- if (m_mode == "instance_weighting")
- m_combineFunction = InstanceWeighting;
- else if (m_mode == "interpolate") {
- m_combineFunction = LinearInterpolationFromCounts;
- } else {
- ostringstream msg;
- msg << "combination mode unknown: " << m_mode;
- throw runtime_error(msg.str());
- }
-
- } else if (args[0] == "lex-e2f") {
- m_lexE2FStr = Tokenize(args[1], ",");
- CHECK(m_lexE2FStr.size() == m_pdStr.size());
- } else if (args[0] == "lex-f2e") {
- m_lexF2EStr = Tokenize(args[1], ",");
- CHECK(m_lexF2EStr.size() == m_pdStr.size());
- }
-
- else if (args[0] == "target-table") {
- m_targetTable = Tokenize(args[1], ",");
- CHECK(m_targetTable.size() == m_pdStr.size());
- }
-
-
-
- } // for
-
-}
-
-bool PhraseDictionaryMultiModelCounts::OverrideParameter(const std::string& key, const std::string& value)
-{
- if (key == "mode") {
- m_mode = value;
- if (m_mode == "instance_weighting")
- m_combineFunction = InstanceWeighting;
- else if (m_mode == "interpolate") {
- m_combineFunction = LinearInterpolationFromCounts;
- } else {
- ostringstream msg;
- msg << "combination mode unknown: " << m_mode;
- throw runtime_error(msg.str());
- }
-
- } else if (key == "lex-e2f") {
- m_lexE2FStr = Tokenize(value, ",");
- CHECK(m_lexE2FStr.size() == m_pdStr.size());
- } else if (key == "lex-f2e") {
- m_lexF2EStr = Tokenize(value, ",");
- CHECK(m_lexF2EStr.size() == m_pdStr.size());
- }
-
- else if (key == "target-table") {
- m_targetTable = Tokenize(value, ",");
- CHECK(m_targetTable.size() == m_pdStr.size());
- }
-
- else {
- PhraseDictionaryMultiModel::OverrideParameter(key, value);
+ 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 {
+ ++ind;
}
+ }
}
PhraseDictionaryMultiModelCounts::~PhraseDictionaryMultiModelCounts()
@@ -742,5 +689,36 @@ double LinearInterpolationFromCounts(vector<float> &joint_counts, vector<float>
return p_weighted;
}
+bool PhraseDictionaryMultiModelCounts::OverrideParameter(const std::string& key, const std::string& value)
+{
+ if (key == "mode") {
+ m_mode = value;
+ if (m_mode == "instance_weighting")
+ m_combineFunction = InstanceWeighting;
+ else if (m_mode == "interpolate") {
+ m_combineFunction = LinearInterpolationFromCounts;
+ } else {
+ ostringstream msg;
+ msg << "combination mode unknown: " << m_mode;
+ throw runtime_error(msg.str());
+ }
+
+ } else if (key == "lex-e2f") {
+ m_lexE2FStr = Tokenize(value, ",");
+ CHECK(m_lexE2FStr.size() == m_pdStr.size());
+ } else if (key == "lex-f2e") {
+ m_lexF2EStr = Tokenize(value, ",");
+ CHECK(m_lexF2EStr.size() == m_pdStr.size());
+ }
+
+ else if (key == "target-table") {
+ m_targetTable = Tokenize(value, ",");
+ CHECK(m_targetTable.size() == m_pdStr.size());
+ }
+
+ else {
+ PhraseDictionaryMultiModel::OverrideParameter(key, value);
+ }
+}
} //namespace
diff --git a/moses/TranslationModel/PhraseDictionaryNodeMemory.h b/moses/TranslationModel/PhraseDictionaryNodeMemory.h
index 136e10c0a..ded1d5097 100644
--- a/moses/TranslationModel/PhraseDictionaryNodeMemory.h
+++ b/moses/TranslationModel/PhraseDictionaryNodeMemory.h
@@ -126,8 +126,8 @@ protected:
TargetPhraseCollection *m_targetPhraseCollection;
PhraseDictionaryNodeMemory()
- :m_targetPhraseCollection(NULL)
- {}
+ :m_targetPhraseCollection(NULL) {
+ }
public:
virtual ~PhraseDictionaryNodeMemory();
diff --git a/moses/TranslationModel/PhraseDictionaryTree.cpp b/moses/TranslationModel/PhraseDictionaryTree.cpp
index ca65fb368..4e9920c40 100644
--- a/moses/TranslationModel/PhraseDictionaryTree.cpp
+++ b/moses/TranslationModel/PhraseDictionaryTree.cpp
@@ -41,8 +41,8 @@ public:
TgtCand(const IPhrase& a, const Scores& b , const std::string& alignment)
: e(a)
, sc(b)
- , m_alignment(alignment)
- {}
+ , m_alignment(alignment) {
+ }
TgtCand(const IPhrase& a,const Scores& b) : e(a),sc(b) {}
diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
index da0ed6d16..e62f69fe7 100644
--- a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
+++ b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
@@ -87,10 +87,5 @@ void PhraseDictionaryOnDisk::InitializeForInput(InputType const& source)
return;
}
-void PhraseDictionaryOnDisk::CleanUpAfterSentenceProcessing(InputType const& source)
-{
-
-}
-
}
diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
index ed470cafb..1586f8036 100644
--- a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
+++ b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
@@ -49,8 +49,8 @@ protected:
public:
PhraseDictionaryOnDisk(const std::string &line)
- : MyBase("PhraseDictionaryOnDisk", line)
- {}
+ : MyBase("PhraseDictionaryOnDisk", line) {
+ }
virtual ~PhraseDictionaryOnDisk();
@@ -67,7 +67,6 @@ public:
const ChartCellCollectionBase &);
virtual void InitializeForInput(InputType const& source);
- virtual void CleanUpAfterSentenceProcessing(InputType const& source);
};
diff --git a/moses/TranslationModel/RuleTable/Trie.h b/moses/TranslationModel/RuleTable/Trie.h
index 965be775e..265747260 100644
--- a/moses/TranslationModel/RuleTable/Trie.h
+++ b/moses/TranslationModel/RuleTable/Trie.h
@@ -41,8 +41,8 @@ class RuleTableTrie : public PhraseDictionary
{
public:
RuleTableTrie(const std::string &description, const std::string &line)
- : PhraseDictionary(description, line)
- {}
+ : PhraseDictionary(description, line) {
+ }
virtual ~RuleTableTrie();
diff --git a/moses/TranslationModel/RuleTable/UTrie.h b/moses/TranslationModel/RuleTable/UTrie.h
index a8f218158..63bf801e8 100644
--- a/moses/TranslationModel/RuleTable/UTrie.h
+++ b/moses/TranslationModel/RuleTable/UTrie.h
@@ -45,8 +45,8 @@ class RuleTableUTrie : public RuleTableTrie
{
public:
RuleTableUTrie(const std::string &line)
- : RuleTableTrie("RuleTableUTrie", line)
- {}
+ : RuleTableTrie("RuleTableUTrie", line) {
+ }
const UTrieNode &GetRootNode() const {
return m_root;
diff --git a/moses/TranslationModel/fuzzy-match/Match.h b/moses/TranslationModel/fuzzy-match/Match.h
index f2ba2c150..eb702850f 100644
--- a/moses/TranslationModel/fuzzy-match/Match.h
+++ b/moses/TranslationModel/fuzzy-match/Match.h
@@ -25,8 +25,8 @@ public:
int max_cost;
int internal_cost;
Match( int is, int ie, int ts, int te, int min, int max, int i )
- :input_start(is), input_end(ie), tm_start(ts), tm_end(te), min_cost(min), max_cost(max), internal_cost(i)
- {}
+ :input_start(is), input_end(ie), tm_start(ts), tm_end(te), min_cost(min), max_cost(max), internal_cost(i) {
+ }
};
}
diff --git a/moses/TranslationModel/fuzzy-match/SentenceAlignment.h b/moses/TranslationModel/fuzzy-match/SentenceAlignment.h
index 466baa149..a777c1eb0 100644
--- a/moses/TranslationModel/fuzzy-match/SentenceAlignment.h
+++ b/moses/TranslationModel/fuzzy-match/SentenceAlignment.h
@@ -21,8 +21,8 @@ struct SentenceAlignment {
std::vector< WORD_ID > target;
std::vector< std::pair<int,int> > alignment;
- SentenceAlignment()
- {}
+ SentenceAlignment() {
+ }
std::string getTargetString(const Vocabulary &vocab) const;
diff --git a/moses/TreeInput.h b/moses/TreeInput.h
index d9fbcc397..511dd0b6d 100644
--- a/moses/TreeInput.h
+++ b/moses/TreeInput.h
@@ -17,8 +17,8 @@ public:
XMLParseOutput(const std::string &label, const WordsRange &range)
: m_label(label)
- , m_range(range)
- {}
+ , m_range(range) {
+ }
};
/** An input to the decoder that represent a parse tree.
@@ -45,8 +45,8 @@ protected:
bool ProcessAndStripXMLTags(std::string &line, std::vector<XMLParseOutput> &sourceLabels, std::vector<XmlOption*> &res);
public:
- TreeInput()
- {}
+ TreeInput() {
+ }
InputTypeEnum GetType() const {
return TreeInputType;
diff --git a/moses/TypeDef.h b/moses/TypeDef.h
index 2b98b5bc3..88011f60a 100644
--- a/moses/TypeDef.h
+++ b/moses/TypeDef.h
@@ -108,27 +108,27 @@ enum DistortionOrientationOptions {
enum PhraseTableImplementation {
Memory = 0
- ,Binary = 1
- ,OnDisk = 2
- //,GlueRule = 3
- //,Joshua = 4
- //,MemorySourceLabel = 5
- ,SCFG = 6
- //,BerkeleyDb = 7
- ,SuffixArray = 8
- ,Hiero = 9
- ,ALSuffixArray = 10
- ,FuzzyMatch = 11
- ,Compact = 12
- ,Interpolated = 13
+ ,Binary = 1
+ ,OnDisk = 2
+ //,GlueRule = 3
+ //,Joshua = 4
+ //,MemorySourceLabel = 5
+ ,SCFG = 6
+ //,BerkeleyDb = 7
+ ,SuffixArray = 8
+ ,Hiero = 9
+ ,ALSuffixArray = 10
+ ,FuzzyMatch = 11
+ ,Compact = 12
+ ,Interpolated = 13
};
enum InputTypeEnum {
SentenceInput = 0
- ,ConfusionNetworkInput = 1
- ,WordLatticeInput = 2
- ,TreeInputType = 3
- ,WordLatticeInput2 = 4
+ ,ConfusionNetworkInput = 1
+ ,WordLatticeInput = 2
+ ,TreeInputType = 3
+ ,WordLatticeInput2 = 4
};
@@ -141,7 +141,7 @@ enum XmlInputType {
enum DictionaryFind {
Best = 0
- ,All = 1
+ ,All = 1
};
enum ParsingAlgorithm {
@@ -151,22 +151,22 @@ enum ParsingAlgorithm {
enum SearchAlgorithm {
Normal = 0
- ,CubePruning = 1
- ,CubeGrowing = 2
- ,ChartDecoding= 3
- ,NormalBatch = 4
- ,ChartIncremental = 5
+ ,CubePruning = 1
+ ,CubeGrowing = 2
+ ,ChartDecoding= 3
+ ,NormalBatch = 4
+ ,ChartIncremental = 5
};
enum SourceLabelOverlap {
SourceLabelOverlapAdd = 0
- ,SourceLabelOverlapReplace = 1
- ,SourceLabelOverlapDiscard = 2
+ ,SourceLabelOverlapReplace = 1
+ ,SourceLabelOverlapDiscard = 2
};
enum WordAlignmentSort {
NoSort = 0
- ,TargetOrder = 1
+ ,TargetOrder = 1
};
enum FormatType {
diff --git a/moses/WordsRange.h b/moses/WordsRange.h
index 23b9a03a2..a6421bf10 100644
--- a/moses/WordsRange.h
+++ b/moses/WordsRange.h
@@ -45,8 +45,8 @@ public:
inline WordsRange(size_t startPos, size_t endPos) : m_startPos(startPos), m_endPos(endPos) {}
inline WordsRange(const WordsRange &copy)
: m_startPos(copy.GetStartPos())
- , m_endPos(copy.GetEndPos())
- {}
+ , m_endPos(copy.GetEndPos()) {
+ }
inline size_t GetStartPos() const {
return m_startPos;
diff --git a/moses/XmlOption.h b/moses/XmlOption.h
index 942446b26..fc5fd4df1 100644
--- a/moses/XmlOption.h
+++ b/moses/XmlOption.h
@@ -20,8 +20,8 @@ struct XmlOption {
TargetPhrase targetPhrase;
XmlOption(const WordsRange &r, const TargetPhrase &tp)
- : range(r), targetPhrase(tp)
- {}
+ : range(r), targetPhrase(tp) {
+ }
};