mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 05:14:36 +03:00
Always have a TargetPhraseCollection.
Before: Name:moses_chart VmPeak:12027904 kB VmRSS:10151884 kB real:173.000 real 2m53.608s user 2m44.003s sys 0m8.401s After: Name:moses_chart VmPeak:11988700 kB VmRSS:10112684 kB real:177.500 real 2m58.393s user 2m39.673s sys 0m12.171s
This commit is contained in:
parent
23c2530617
commit
1b3f769c5c
@ -36,6 +36,7 @@ class TargetPhraseCollection
|
||||
protected:
|
||||
friend std::ostream& operator<<(std::ostream &, const TargetPhraseCollection &);
|
||||
|
||||
// TODO boost::ptr_vector
|
||||
std::vector<TargetPhrase*> m_collection;
|
||||
|
||||
public:
|
||||
@ -57,7 +58,7 @@ public:
|
||||
}
|
||||
|
||||
~TargetPhraseCollection() {
|
||||
RemoveAllInColl(m_collection);
|
||||
Clear();
|
||||
}
|
||||
|
||||
const std::vector<TargetPhrase*> &GetCollection() const {
|
||||
@ -83,6 +84,10 @@ public:
|
||||
void Prune(bool adhereTableLimit, size_t tableLimit);
|
||||
void Sort(bool adhereTableLimit, size_t tableLimit);
|
||||
|
||||
void Clear() {
|
||||
RemoveAllInColl(m_collection);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -70,14 +70,7 @@ const TargetPhraseCollection *PhraseDictionaryMemory::GetTargetPhraseCollection(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const TargetPhraseCollection *coll = currNode->GetTargetPhraseCollection();
|
||||
/*
|
||||
if (coll) {
|
||||
cerr << "source=" << source << endl
|
||||
<< *coll << endl;
|
||||
}
|
||||
*/
|
||||
return coll;
|
||||
return currNode->GetTargetPhraseCollection();
|
||||
}
|
||||
|
||||
PhraseDictionaryNodeMemory &PhraseDictionaryMemory::GetOrCreateNode(const Phrase &source
|
||||
|
@ -38,14 +38,6 @@ PhraseDictionaryNodeMemory::~PhraseDictionaryNodeMemory()
|
||||
const PhraseDictionaryNodeMemory *node = iter->second;
|
||||
delete node;
|
||||
}
|
||||
delete m_targetPhraseCollection;
|
||||
}
|
||||
|
||||
TargetPhraseCollection &PhraseDictionaryNodeMemory::GetOrCreateTargetPhraseCollection()
|
||||
{
|
||||
if (m_targetPhraseCollection == NULL)
|
||||
m_targetPhraseCollection = new TargetPhraseCollection();
|
||||
return *m_targetPhraseCollection;
|
||||
}
|
||||
|
||||
void PhraseDictionaryNodeMemory::Prune(size_t tableLimit)
|
||||
@ -59,8 +51,7 @@ void PhraseDictionaryNodeMemory::Prune(size_t tableLimit)
|
||||
}
|
||||
|
||||
// prune TargetPhraseCollection in this node
|
||||
if (m_targetPhraseCollection != NULL)
|
||||
m_targetPhraseCollection->Prune(true, tableLimit);
|
||||
m_targetPhraseCollection.Prune(true, tableLimit);
|
||||
}
|
||||
|
||||
void PhraseDictionaryNodeMemory::Sort(size_t tableLimit)
|
||||
@ -74,9 +65,7 @@ void PhraseDictionaryNodeMemory::Sort(size_t tableLimit)
|
||||
}
|
||||
|
||||
// prune TargetPhraseCollection in this node
|
||||
if (m_targetPhraseCollection != NULL) {
|
||||
m_targetPhraseCollection->Sort(true, tableLimit);
|
||||
}
|
||||
m_targetPhraseCollection.Sort(true, tableLimit);
|
||||
}
|
||||
|
||||
PhraseDictionaryNodeMemory *PhraseDictionaryNodeMemory::GetOrCreateChild(const Word &sourceTerm)
|
||||
@ -138,8 +127,7 @@ void PhraseDictionaryNodeMemory::Clear()
|
||||
{
|
||||
m_sourceTermMap.clear();
|
||||
m_nonTermMap.clear();
|
||||
delete m_targetPhraseCollection;
|
||||
|
||||
m_targetPhraseCollection.Clear();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream &out, const PhraseDictionaryNodeMemory &node)
|
||||
|
@ -120,14 +120,12 @@ private:
|
||||
friend class std::map<Word, PhraseDictionaryNodeMemory>;
|
||||
friend class std::map<long, PhraseDictionaryNodeMemory>;
|
||||
|
||||
protected:
|
||||
TerminalMap m_sourceTermMap;
|
||||
NonTerminalMap m_nonTermMap;
|
||||
TargetPhraseCollection *m_targetPhraseCollection;
|
||||
TargetPhraseCollection m_targetPhraseCollection;
|
||||
|
||||
PhraseDictionaryNodeMemory() {}
|
||||
|
||||
PhraseDictionaryNodeMemory()
|
||||
:m_targetPhraseCollection(NULL) {
|
||||
}
|
||||
public:
|
||||
~PhraseDictionaryNodeMemory();
|
||||
|
||||
@ -143,9 +141,11 @@ public:
|
||||
const PhraseDictionaryNodeMemory *GetChild(const Word &sourceNonTerm, const Word &targetNonTerm) const;
|
||||
|
||||
const TargetPhraseCollection *GetTargetPhraseCollection() const {
|
||||
return &m_targetPhraseCollection;
|
||||
}
|
||||
TargetPhraseCollection &GetOrCreateTargetPhraseCollection() {
|
||||
return m_targetPhraseCollection;
|
||||
}
|
||||
TargetPhraseCollection &GetOrCreateTargetPhraseCollection();
|
||||
|
||||
const NonTerminalMap & GetNonTerminalMap() const {
|
||||
return m_nonTermMap;
|
||||
|
Loading…
Reference in New Issue
Block a user