mosesdecoder/moses/TranslationModel/RuleTable/PhraseDictionaryALSuffixArray.cpp

54 lines
1.4 KiB
C++
Raw Normal View History

//
// PhraseDictionaryALSuffixArray.cpp
// moses
//
// Created by Hieu Hoang on 06/11/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#include <iostream>
#include "PhraseDictionaryALSuffixArray.h"
2012-11-12 23:56:18 +04:00
#include "moses/InputType.h"
#include "moses/InputFileStream.h"
#include "moses/TypeDef.h"
#include "moses/StaticData.h"
#include "moses/UserMessage.h"
#include "Loader.h"
#include "LoaderFactory.h"
using namespace std;
2013-05-29 21:16:15 +04:00
namespace Moses
{
2013-05-28 16:11:37 +04:00
PhraseDictionaryALSuffixArray::PhraseDictionaryALSuffixArray(const std::string &line)
2013-05-29 21:16:15 +04:00
: PhraseDictionaryMemory("PhraseDictionaryALSuffixArray", line)
{
const StaticData &staticData = StaticData::Instance();
2013-05-28 16:11:37 +04:00
if (staticData.ThreadCount() > 1) {
2013-05-29 21:16:15 +04:00
throw runtime_error("Suffix array implementation is not threadsafe");
}
CHECK(m_args.size() == 0);
}
void PhraseDictionaryALSuffixArray::InitializeForInput(InputType const& source)
{
// populate with rules for this sentence
long translationId = source.GetTranslationId();
2013-05-29 21:16:15 +04:00
string grammarFile = GetFilePath() + "/grammar." + SPrint(translationId) + ".gz";
2013-05-29 21:16:15 +04:00
std::auto_ptr<RuleTableLoader> loader =
2013-05-29 21:16:15 +04:00
RuleTableLoaderFactory::Create(grammarFile);
bool ret = loader->Load(m_input, m_output, grammarFile, m_tableLimit,
*this);
2013-05-29 21:16:15 +04:00
CHECK(ret);
}
void PhraseDictionaryALSuffixArray::CleanUpAfterSentenceProcessing(const InputType &source)
{
m_collection.Clear();
}
}