mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-01 16:33:16 +03:00
make pools mutable. Can't pass no-const mgr or system
This commit is contained in:
parent
2e85a318cb
commit
0f7d4ffd79
@ -13,20 +13,20 @@
|
||||
using namespace std;
|
||||
|
||||
Manager::Manager(System &system, const std::string &inputStr)
|
||||
:m_pool(system.GetManagerPool())
|
||||
:m_pool(&system.GetManagerPool())
|
||||
,m_system(system)
|
||||
,m_initRange(NOT_FOUND, NOT_FOUND)
|
||||
,m_initPhrase(system.GetManagerPool(), system, 0)
|
||||
{
|
||||
Moses::FactorCollection &vocab = system.GetVocab();
|
||||
|
||||
m_input = Phrase::CreateFromString(m_pool, vocab, inputStr);
|
||||
m_input = Phrase::CreateFromString(GetPool(), vocab, inputStr);
|
||||
m_inputPaths.Init(*m_input, system);
|
||||
|
||||
const std::vector<const PhraseTable*> &pts = system.GetFeatureFunctions().GetPhraseTables();
|
||||
for (size_t i = 0; i < pts.size(); ++i) {
|
||||
const PhraseTable &pt = *pts[i];
|
||||
pt.Lookup(m_inputPaths);
|
||||
pt.Lookup(*this, m_inputPaths);
|
||||
}
|
||||
|
||||
m_stacks.resize(m_input->GetSize() + 1);
|
||||
|
@ -25,8 +25,8 @@ public:
|
||||
Manager(System &system, const std::string &inputStr);
|
||||
virtual ~Manager();
|
||||
|
||||
MemPool &GetPool()
|
||||
{ return m_pool; }
|
||||
MemPool &GetPool() const
|
||||
{ return *m_pool; }
|
||||
|
||||
const System &GetSystem() const
|
||||
{ return m_system; }
|
||||
@ -41,7 +41,7 @@ public:
|
||||
|
||||
void Decode();
|
||||
protected:
|
||||
MemPool &m_pool;
|
||||
mutable MemPool *m_pool;
|
||||
|
||||
const System &m_system;
|
||||
Phrase *m_input;
|
||||
|
@ -39,11 +39,11 @@ void PhraseTable::SetParameter(const std::string& key, const std::string& value)
|
||||
}
|
||||
}
|
||||
|
||||
void PhraseTable::Lookup(InputPaths &inputPaths) const
|
||||
void PhraseTable::Lookup(const Manager &mgr, InputPaths &inputPaths) const
|
||||
{
|
||||
BOOST_FOREACH(InputPath &path, inputPaths) {
|
||||
const SubPhrase &phrase = path.GetSubPhrase();
|
||||
const TargetPhrases *tps = Lookup(path);
|
||||
const TargetPhrases *tps = Lookup(mgr, path);
|
||||
cerr << "path=" << path << endl;
|
||||
cerr << "tps=" << tps << endl;
|
||||
if (tps) {
|
||||
@ -55,7 +55,7 @@ void PhraseTable::Lookup(InputPaths &inputPaths) const
|
||||
|
||||
}
|
||||
|
||||
const TargetPhrases *PhraseTable::Lookup(InputPath &inputPath) const
|
||||
const TargetPhrases *PhraseTable::Lookup(const Manager &mgr, InputPath &inputPath) const
|
||||
{
|
||||
UTIL_THROW2("Not implemented");
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
class System;
|
||||
class InputPaths;
|
||||
class InputPath;
|
||||
class Manager;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
class PhraseTable : public StatelessFeatureFunction
|
||||
@ -24,8 +25,8 @@ public:
|
||||
virtual ~PhraseTable();
|
||||
|
||||
virtual void SetParameter(const std::string& key, const std::string& value);
|
||||
virtual void Lookup(InputPaths &inputPaths) const;
|
||||
virtual const TargetPhrases *Lookup(InputPath &inputPath) const;
|
||||
virtual void Lookup(const Manager &mgr, InputPaths &inputPaths) const;
|
||||
virtual const TargetPhrases *Lookup(const Manager &mgr, InputPath &inputPath) const;
|
||||
|
||||
void SetPtInd(size_t ind)
|
||||
{ m_ptInd = ind; }
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
MemPool &GetSystemPool()
|
||||
{ return m_systemPool; }
|
||||
|
||||
MemPool &GetManagerPool()
|
||||
MemPool &GetManagerPool() const
|
||||
{ return m_managerPool; }
|
||||
|
||||
Moses::FactorCollection &GetVocab() const
|
||||
@ -45,7 +45,7 @@ protected:
|
||||
|
||||
mutable Moses::FactorCollection m_vocab;
|
||||
MemPool m_systemPool;
|
||||
MemPool m_managerPool;
|
||||
mutable MemPool m_managerPool;
|
||||
FeatureFunctions m_featureFunctions;
|
||||
Weights m_weights;
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
* Author: hieu
|
||||
*/
|
||||
|
||||
#include <contrib/other-builds/moses2/UnknownWordPenalty.h>
|
||||
#include "UnknownWordPenalty.h"
|
||||
#include "Manager.h"
|
||||
|
||||
UnknownWordPenalty::UnknownWordPenalty(size_t startInd, const std::string &line)
|
||||
:PhraseTable(startInd, line)
|
||||
@ -18,7 +19,13 @@ UnknownWordPenalty::~UnknownWordPenalty() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
const TargetPhrases *UnknownWordPenalty::Lookup(InputPath &inputPath) const
|
||||
const TargetPhrases *UnknownWordPenalty::Lookup(const Manager &mgr, InputPath &inputPath) const
|
||||
{
|
||||
TargetPhrases *tps = new TargetPhrases();
|
||||
|
||||
MemPool &pool = mgr.GetPool();
|
||||
const System &system = mgr.GetSystem();
|
||||
|
||||
//TargetPhrase *tp = new (pool.Allocate<TargetPhrase>()) TargetPhrase(pool, system, 1);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
UnknownWordPenalty(size_t startInd, const std::string &line);
|
||||
virtual ~UnknownWordPenalty();
|
||||
|
||||
virtual const TargetPhrases *Lookup(InputPath &inputPath) const;
|
||||
virtual const TargetPhrases *Lookup(const Manager &mgr, InputPath &inputPath) const;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user