mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-29 06:52:34 +03:00
set set<ptr> rather than set<object>
This commit is contained in:
parent
715af8bcad
commit
efee9f8f95
@ -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)
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
|
||||
std::vector<int> corners;
|
||||
|
||||
ConsistentPhrase(const ConsistentPhrase ©);
|
||||
ConsistentPhrase(const ConsistentPhrase ©); // do not implement
|
||||
ConsistentPhrase(int sourceStart, int sourceEnd,
|
||||
int targetStart, int targetEnd);
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <cassert>
|
||||
#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<Coll> &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<Coll::iterator, bool> 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;
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class Word;
|
||||
|
||||
class ConsistentPhrases {
|
||||
public:
|
||||
typedef std::set<ConsistentPhrase> Coll;
|
||||
typedef std::set<ConsistentPhrase*> Coll;
|
||||
|
||||
ConsistentPhrases();
|
||||
virtual ~ConsistentPhrases();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user