2015-10-23 22:53:36 +03:00
|
|
|
/*
|
|
|
|
* Manager.cpp
|
|
|
|
*
|
|
|
|
* Created on: 23 Oct 2015
|
|
|
|
* Author: hieu
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Manager.h"
|
2015-10-24 14:39:15 +03:00
|
|
|
#include "PhraseTable.h"
|
|
|
|
#include "StaticData.h"
|
2015-10-25 14:47:47 +03:00
|
|
|
#include "SearchNormal.h"
|
|
|
|
|
|
|
|
using namespace std;
|
2015-10-23 22:53:36 +03:00
|
|
|
|
2015-10-24 05:32:30 +03:00
|
|
|
Manager::Manager(const StaticData &staticData, const std::string &inputStr)
|
2015-10-23 22:53:36 +03:00
|
|
|
:m_staticData(staticData)
|
2015-10-25 15:49:25 +03:00
|
|
|
,m_initRange(NOT_FOUND, NOT_FOUND)
|
2015-10-23 22:53:36 +03:00
|
|
|
{
|
2015-10-24 05:32:30 +03:00
|
|
|
m_input = Phrase::CreateFromString(m_pool, inputStr);
|
2015-10-24 15:31:43 +03:00
|
|
|
m_inputPaths.Init(*m_input, staticData);
|
2015-10-24 14:39:15 +03:00
|
|
|
|
|
|
|
const std::vector<const PhraseTable*> &pts = staticData.GetPhraseTables();
|
|
|
|
for (size_t i = 0; i < pts.size(); ++i) {
|
|
|
|
const PhraseTable &pt = *pts[i];
|
|
|
|
pt.Lookups(m_inputPaths);
|
|
|
|
}
|
2015-10-24 21:54:16 +03:00
|
|
|
|
|
|
|
m_stacks.resize(m_input->GetSize());
|
2015-10-25 14:47:47 +03:00
|
|
|
m_bitmaps = new Moses::Bitmaps(m_input->GetSize(), vector<bool>(0));
|
|
|
|
m_search = new SearchNormal(*this, m_stacks);
|
2015-10-23 22:53:36 +03:00
|
|
|
}
|
|
|
|
|
2015-10-24 15:31:43 +03:00
|
|
|
void Manager::Decode()
|
|
|
|
{
|
2015-10-25 18:58:26 +03:00
|
|
|
const Moses::Bitmap &initBitmap = m_bitmaps->GetInitialBitmap();
|
2015-10-25 15:49:25 +03:00
|
|
|
Hypothesis *iniHypo = new (GetPool().Allocate<Hypothesis>()) Hypothesis(*this, initBitmap, m_initRange);
|
2015-10-24 15:31:43 +03:00
|
|
|
|
2015-10-25 14:47:47 +03:00
|
|
|
for (size_t i = 0; i < m_stacks.size(); ++i) {
|
|
|
|
m_search->Decode(i);
|
|
|
|
}
|
2015-10-24 15:31:43 +03:00
|
|
|
}
|
|
|
|
|
2015-10-23 22:53:36 +03:00
|
|
|
Manager::~Manager() {
|
2015-10-25 14:47:47 +03:00
|
|
|
delete m_bitmaps;
|
|
|
|
delete m_search;
|
2015-10-23 22:53:36 +03:00
|
|
|
}
|
|
|
|
|