From efee9f8f953ed6158c27ff138ba8bcc84c30f49a Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Thu, 27 Feb 2014 14:59:23 +0000 Subject: [PATCH] set set rather than set --- .../extract-mixed-syntax/ConsistentPhrase.cpp | 12 ---------- .../extract-mixed-syntax/ConsistentPhrase.h | 2 +- .../ConsistentPhrases.cpp | 24 ++++++++++++------- .../extract-mixed-syntax/ConsistentPhrases.h | 2 +- .../extract-mixed-syntax/Rules.cpp | 4 ++-- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/contrib/other-builds/extract-mixed-syntax/ConsistentPhrase.cpp b/contrib/other-builds/extract-mixed-syntax/ConsistentPhrase.cpp index 57ba043b9..f9240e96d 100644 --- a/contrib/other-builds/extract-mixed-syntax/ConsistentPhrase.cpp +++ b/contrib/other-builds/extract-mixed-syntax/ConsistentPhrase.cpp @@ -11,18 +11,6 @@ using namespace std; -ConsistentPhrase::ConsistentPhrase(const ConsistentPhrase ©) -:corners(copy.corners) -{ - for (size_t i = 0; i < copy.m_nonTerms.size(); ++i) { - const NonTerm &oldNonTerm = copy.m_nonTerms[i]; - - m_nonTerms.push_back(NonTerm (*this, - oldNonTerm.GetLabel(Moses::Input), - oldNonTerm.GetLabel(Moses::Output))); - } -} - ConsistentPhrase::ConsistentPhrase( int sourceStart, int sourceEnd, int targetStart, int targetEnd) diff --git a/contrib/other-builds/extract-mixed-syntax/ConsistentPhrase.h b/contrib/other-builds/extract-mixed-syntax/ConsistentPhrase.h index df9ed0b26..2306fc5b4 100644 --- a/contrib/other-builds/extract-mixed-syntax/ConsistentPhrase.h +++ b/contrib/other-builds/extract-mixed-syntax/ConsistentPhrase.h @@ -20,7 +20,7 @@ public: std::vector corners; - ConsistentPhrase(const ConsistentPhrase ©); + ConsistentPhrase(const ConsistentPhrase ©); // do not implement ConsistentPhrase(int sourceStart, int sourceEnd, int targetStart, int targetEnd); diff --git a/contrib/other-builds/extract-mixed-syntax/ConsistentPhrases.cpp b/contrib/other-builds/extract-mixed-syntax/ConsistentPhrases.cpp index 245ee1394..4c1e86093 100644 --- a/contrib/other-builds/extract-mixed-syntax/ConsistentPhrases.cpp +++ b/contrib/other-builds/extract-mixed-syntax/ConsistentPhrases.cpp @@ -8,6 +8,7 @@ #include #include "ConsistentPhrases.h" #include "NonTerm.h" +#include "moses/Util.h" using namespace std; @@ -16,7 +17,14 @@ ConsistentPhrases::ConsistentPhrases() } ConsistentPhrases::~ConsistentPhrases() { - // TODO Auto-generated destructor stub + for (int start = 0; start < m_coll.size(); ++start) { + std::vector &allSourceStart = m_coll[start]; + + for (int size = 0; size < allSourceStart.size(); ++size) { + Coll &coll = allSourceStart[size]; + Moses::RemoveAllInColl(coll); + } + } } void ConsistentPhrases::Initialize(size_t size) @@ -33,16 +41,14 @@ void ConsistentPhrases::Add(int sourceStart, int sourceEnd, int targetStart, int targetEnd) { Coll &coll = m_coll[sourceStart][sourceEnd - sourceStart]; - ConsistentPhrase cp(sourceStart, - sourceEnd, - targetStart, - targetEnd); - cp.AddNonTerms("[X]", "[X]"); + ConsistentPhrase *cp = new ConsistentPhrase(sourceStart, + sourceEnd, + targetStart, + targetEnd); + cp->AddNonTerms("[X]", "[X]"); pair inserted = coll.insert(cp); assert(inserted.second); - - const ConsistentPhrase &cpNew = *inserted.first; } @@ -64,7 +70,7 @@ std::string ConsistentPhrases::Debug() const Coll::const_iterator iter; for (iter = coll.begin(); iter != coll.end(); ++iter) { - const ConsistentPhrase &consistentPhrase = *iter; + const ConsistentPhrase &consistentPhrase = **iter; out << consistentPhrase.Debug() << endl; } } diff --git a/contrib/other-builds/extract-mixed-syntax/ConsistentPhrases.h b/contrib/other-builds/extract-mixed-syntax/ConsistentPhrases.h index ff531d674..a3a124f0a 100644 --- a/contrib/other-builds/extract-mixed-syntax/ConsistentPhrases.h +++ b/contrib/other-builds/extract-mixed-syntax/ConsistentPhrases.h @@ -15,7 +15,7 @@ class Word; class ConsistentPhrases { public: - typedef std::set Coll; + typedef std::set Coll; ConsistentPhrases(); virtual ~ConsistentPhrases(); diff --git a/contrib/other-builds/extract-mixed-syntax/Rules.cpp b/contrib/other-builds/extract-mixed-syntax/Rules.cpp index bbd8c0c9b..ae1421837 100644 --- a/contrib/other-builds/extract-mixed-syntax/Rules.cpp +++ b/contrib/other-builds/extract-mixed-syntax/Rules.cpp @@ -63,7 +63,7 @@ void Rules::Extend(const Parameter ¶ms) ConsistentPhrases::Coll::const_iterator iter; for (iter = cps.begin(); iter != cps.end(); ++iter) { - const ConsistentPhrase &cp = *iter; + const ConsistentPhrase &cp = **iter; CreateRules(cp, params); } } @@ -95,7 +95,7 @@ void Rules::Extend(const Rule &rule, const ConsistentPhrases::Coll &cps, const P { ConsistentPhrases::Coll::const_iterator iter; for (iter = cps.begin(); iter != cps.end(); ++iter) { - const ConsistentPhrase &cp = *iter; + const ConsistentPhrase &cp = **iter; Extend(rule, cp, params); } }