diff --git a/contrib/other-builds/extract-rules/.project b/contrib/other-builds/extract-rules/.project index 76de5a624..29ffed2a9 100644 --- a/contrib/other-builds/extract-rules/.project +++ b/contrib/other-builds/extract-rules/.project @@ -65,6 +65,11 @@ 1 PARENT-3-PROJECT_LOC/phrase-extract/OutputFileStream.h + + RuleExtractionOptions.h + 1 + PARENT-3-PROJECT_LOC/phrase-extract/RuleExtractionOptions.h + SentenceAlignment.cpp 1 diff --git a/contrib/other-builds/moses-chart-cmd/.cproject b/contrib/other-builds/moses-chart-cmd/.cproject index b6cbc127d..86dfbac5b 100644 --- a/contrib/other-builds/moses-chart-cmd/.cproject +++ b/contrib/other-builds/moses-chart-cmd/.cproject @@ -5,13 +5,13 @@ - - + + @@ -70,7 +70,6 @@ - @@ -108,13 +107,13 @@ - - + + diff --git a/contrib/other-builds/moses-cmd/.cproject b/contrib/other-builds/moses-cmd/.cproject index f9eeebf1d..828b71395 100644 --- a/contrib/other-builds/moses-cmd/.cproject +++ b/contrib/other-builds/moses-cmd/.cproject @@ -5,13 +5,13 @@ - - + + @@ -71,7 +71,6 @@ - @@ -109,13 +108,13 @@ - - + + diff --git a/mert/FeatureStats.cpp b/mert/FeatureStats.cpp index aa32e1fef..5a12be70a 100644 --- a/mert/FeatureStats.cpp +++ b/mert/FeatureStats.cpp @@ -181,10 +181,8 @@ FeatureStats::FeatureStats(const size_t size) FeatureStats::~FeatureStats() { - if (m_array) { - delete [] m_array; - m_array = NULL; - } + delete [] m_array; + m_array = NULL; } void FeatureStats::Copy(const FeatureStats &stats) diff --git a/mert/ScoreStats.cpp b/mert/ScoreStats.cpp index 1c66cdb5f..771880fa1 100644 --- a/mert/ScoreStats.cpp +++ b/mert/ScoreStats.cpp @@ -35,10 +35,8 @@ ScoreStats::ScoreStats(const size_t size) ScoreStats::~ScoreStats() { - if (m_array) { - delete [] m_array; - m_array = NULL; - } + delete [] m_array; + m_array = NULL; } void ScoreStats::Copy(const ScoreStats &stats) @@ -157,4 +155,4 @@ bool operator==(const ScoreStats& s1, const ScoreStats& s2) return true; } -} \ No newline at end of file +} diff --git a/mert/Singleton.h b/mert/Singleton.h index f50925fa4..df1386650 100644 --- a/mert/Singleton.h +++ b/mert/Singleton.h @@ -21,10 +21,8 @@ public: } static void Delete() { - if (m_instance) { - delete m_instance; - m_instance = NULL; - } + delete m_instance; + m_instance = NULL; } private: diff --git a/moses/FF/LexicalReordering/LexicalReordering.cpp b/moses/FF/LexicalReordering/LexicalReordering.cpp index c73c0324b..6a2a488d9 100644 --- a/moses/FF/LexicalReordering/LexicalReordering.cpp +++ b/moses/FF/LexicalReordering/LexicalReordering.cpp @@ -52,8 +52,7 @@ LexicalReordering::LexicalReordering(const std::string &line) LexicalReordering::~LexicalReordering() { - if(m_table) - delete m_table; + delete m_table; delete m_configuration; } diff --git a/moses/StaticData.cpp b/moses/StaticData.cpp index 782144360..3a529c230 100644 --- a/moses/StaticData.cpp +++ b/moses/StaticData.cpp @@ -1184,5 +1184,52 @@ void StaticData::CheckLEGACYPT() } +void StaticData::ResetWeights(const std::string &denseWeights, const std::string &sparseFile) +{ + m_allWeights = ScoreComponentCollection(); + + // dense weights + string name(""); + vector weights; + vector toks = Tokenize(denseWeights); + for (size_t i = 0; i < toks.size(); ++i) { + const string &tok = toks[i]; + + if (tok.substr(tok.size() - 1, 1) == "=") { + // start of new feature + + if (name != "") { + // save previous ff + const FeatureFunction &ff = FeatureFunction::FindFeatureFunction(name); + m_allWeights.Assign(&ff, weights); + weights.clear(); + } + + name = tok.substr(0, tok.size() - 1); + } else { + // a weight for curr ff + float weight = Scan(toks[i]); + weights.push_back(weight); + } + } + + const FeatureFunction &ff = FeatureFunction::FindFeatureFunction(name); + m_allWeights.Assign(&ff, weights); + + // sparse weights + InputFileStream sparseStrme(sparseFile); + string line; + while (getline(sparseStrme, line)) { + vector toks = Tokenize(line); + UTIL_THROW_IF2(toks.size() != 2, "Incorrect sparse weight format. Should be FFName_spareseName weight"); + + vector names = Tokenize(toks[0], "_"); + UTIL_THROW_IF2(names.size() != 2, "Incorrect sparse weight name. Should be FFName_spareseName"); + + const FeatureFunction &ff = FeatureFunction::FindFeatureFunction(names[0]); + m_allWeights.Assign(&ff, names[1], Scan(toks[1])); + } +} + } // namespace diff --git a/moses/StaticData.h b/moses/StaticData.h index def81afae..1eff959cc 100644 --- a/moses/StaticData.h +++ b/moses/StaticData.h @@ -756,6 +756,9 @@ public: bool AdjacentOnly() const { return m_adjacentOnly; } + + + void ResetWeights(const std::string &denseWeights, const std::string &sparseFile); }; } diff --git a/moses/TranslationModel/DynSAInclude/onlineRLM.h b/moses/TranslationModel/DynSAInclude/onlineRLM.h index 929602399..1e7a9c2d6 100644 --- a/moses/TranslationModel/DynSAInclude/onlineRLM.h +++ b/moses/TranslationModel/DynSAInclude/onlineRLM.h @@ -43,10 +43,10 @@ public: alpha_[i] = i * log10(0.4); } ~OnlineRLM() { - if(alpha_) delete[] alpha_; + delete[] alpha_; if(bAdapting_) delete vocab_; else vocab_ = NULL; - if(cache_) delete cache_; + delete cache_; delete bPrefix_; delete bHit_; }