load binary pt

This commit is contained in:
Hieu Hoang 2013-02-25 11:49:34 +00:00
parent 682aaf4c6f
commit c789ce81e6
4 changed files with 18 additions and 26 deletions

View File

@ -476,6 +476,9 @@ void Parameter::ConvertWeightArgsPhraseModel(const string &oldWeightName)
case Memory:
ptType = "PhraseDictionaryMemory";
break;
case Binary:
ptType = "PhraseDictionaryTreeAdaptor";
break;
}
// weights

View File

@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <string>
#include "util/check.hh"
#include "moses/TranslationModel/PhraseDictionaryMemory.h"
#include "moses/TranslationModel/PhraseDictionaryTreeAdaptor.h"
#include "DecodeStepTranslation.h"
#include "DecodeStepGeneration.h"
#include "GenerationDictionary.h"
@ -648,17 +649,15 @@ bool StaticData::LoadData(Parameter *parameter)
SetWeights(model, weights);
m_unknownWordPenaltyProducer = model;
}
/*
else if (feature == "PhraseModel") {
PhraseDictionaryFeature* model = new PhraseDictionaryFeature(line);
else if (feature == "PhraseDictionaryMemory") {
PhraseDictionaryMemory* model = new PhraseDictionaryMemory(line);
vector<float> weights = m_parameter->GetWeights(feature, featureIndex);
SetWeights(model, weights);
m_phraseDictionary.push_back(model);
}
*/
else if (feature == "PhraseDictionaryMemory") {
else if (feature == "PhraseDictionaryTreeAdaptor") {
cerr << endl << line << endl;
PhraseDictionaryMemory* model = new PhraseDictionaryMemory(line);
PhraseDictionaryTreeAdaptor* model = new PhraseDictionaryTreeAdaptor(line);
vector<float> weights = m_parameter->GetWeights(feature, featureIndex);
SetWeights(model, weights);
m_phraseDictionary.push_back(model);

View File

@ -15,6 +15,8 @@
#include "moses/PDTAimp.h"
#include "moses/UserMessage.h"
using namespace std;
namespace Moses
{
/*************************************************************
@ -35,15 +37,13 @@ PhraseDictionaryTreeAdaptor::~PhraseDictionaryTreeAdaptor()
delete imp;
}
bool PhraseDictionaryTreeAdaptor::Load(const std::vector<FactorType> &input
, const std::vector<FactorType> &output
, const std::string &filePath
, const std::vector<float> &weight
, size_t tableLimit
, const LMList &languageModels
, float weightWP)
bool PhraseDictionaryTreeAdaptor::InitDictionary()
{
const StaticData &staticData = StaticData::Instance();
vector<float> weight = staticData.GetWeights(this);
const LMList &languageModels = staticData.GetLMList();
if(m_numScoreComponents!=weight.size()) {
std::stringstream strme;
strme << "ERROR: mismatch of number of scaling factors: "<<weight.size()
@ -52,11 +52,7 @@ bool PhraseDictionaryTreeAdaptor::Load(const std::vector<FactorType> &input
return false;
}
// set PhraseDictionary members
m_tableLimit=tableLimit;
imp->Create(input,output,filePath,weight,languageModels);
imp->Create(m_input, m_output, m_filePath, weight, languageModels);
return true;
}

View File

@ -43,13 +43,7 @@ public:
void DisableCache();
// initialize ...
bool Load(const std::vector<FactorType> &input
, const std::vector<FactorType> &output
, const std::string &filePath
, const std::vector<float> &weight
, size_t tableLimit
, const LMList &languageModels
, float weightWP);
bool InitDictionary();
// get translation candidates for a given source phrase
// returns null pointer if nothing found