Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2013-01-28 21:33:45 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-01-28 21:33:45 +0400
commit00ebc1e5abf513e8902eb7877d3acd2d50579279 (patch)
tree454fc1a1d2495b5225c3c217a4b8faf1d737b87f /moses/SyntacticLanguageModel.cpp
parent49345b6b56616e5f4b5720bca9f01d4d5cc0c794 (diff)
refactor Syntactic LM. Can't find dependencies to do this properly. Ask Lane later on
Diffstat (limited to 'moses/SyntacticLanguageModel.cpp')
-rw-r--r--moses/SyntacticLanguageModel.cpp66
1 files changed, 56 insertions, 10 deletions
diff --git a/moses/SyntacticLanguageModel.cpp b/moses/SyntacticLanguageModel.cpp
index 662068045..4a3b26ff1 100644
--- a/moses/SyntacticLanguageModel.cpp
+++ b/moses/SyntacticLanguageModel.cpp
@@ -10,21 +10,67 @@
namespace Moses
{
- // asnteousntaoheisnthaoesntih
- SyntacticLanguageModel::SyntacticLanguageModel(const std::vector<std::string>& filePath,
- const std::vector<float>& weights,
- const FactorType factorType,
- size_t beamWidth)
- // Initialize member variables
+ SyntacticLanguageModel::SyntacticLanguageModel(const std::string &line)
+ // Initialize member variables
+ /*
: m_NumScoreComponents(weights.size())
, m_files(new SyntacticLanguageModelFiles<YModel,XModel>(filePath))
, m_factorType(factorType)
, m_beamWidth(beamWidth) {
+ */
+ {
+ /* taken from StaticData::LoadSyntacticLanguageModel()
+ cerr << "Loading syntactic language models..." << std::endl;
+
+ const vector<float> weights = Scan<float>(m_parameter->GetParam("weight-slm"));
+ const vector<string> files = m_parameter->GetParam("slmodel-file");
+
+ const FactorType factorType = (m_parameter->GetParam("slmodel-factor").size() > 0) ?
+ TransformScore(Scan<int>(m_parameter->GetParam("slmodel-factor")[0]))
+ : 0;
+
+ const size_t beamWidth = (m_parameter->GetParam("slmodel-beam").size() > 0) ?
+ TransformScore(Scan<int>(m_parameter->GetParam("slmodel-beam")[0]))
+ : 500;
+
+ if (files.size() < 1) {
+ cerr << "No syntactic language model files specified!" << std::endl;
+ return false;
+ }
+
+ // check if feature is used
+ if (weights.size() >= 1) {
+
+ //cout.setf(ios::scientific,ios::floatfield);
+ //cerr.setf(ios::scientific,ios::floatfield);
+
+ // create the feature
+ m_syntacticLanguageModel = new SyntacticLanguageModel(files,weights,factorType,beamWidth);
+
+
+ /////////////////////////////////////////
+ // BEGIN LANE's UNSTABLE EXPERIMENT :)
+ //
+
+ //double ppl = m_syntacticLanguageModel->perplexity();
+ //cerr << "Probability is " << ppl << endl;
+
+
+ //
+ // END LANE's UNSTABLE EXPERIMENT
+ /////////////////////////////////////////
+
+
+
+ if (m_syntacticLanguageModel==NULL) {
+ return false;
+ }
+
+ }
+
+ return true;
- // Inform Moses score manager of this feature and its weight(s)
- const_cast<ScoreIndexManager&>(StaticData::Instance().GetScoreIndexManager()).AddScoreProducer(this);
- const_cast<StaticData&>(StaticData::Instance()).SetWeightsForScoreProducer(this, weights);
- VERBOSE(3,"Constructed SyntacticLanguageModel" << endl);
+ */
}
SyntacticLanguageModel::~SyntacticLanguageModel() {