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
path: root/moses2
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2020-10-01 20:03:32 +0300
committerHieu Hoang <hieuhoang@gmail.com>2020-10-01 20:03:32 +0300
commit1adc2f9f94ca433095ca6d75a57acb2235a0a03f (patch)
treebd6ef6af141a2a1823bccaca2aa1a1ecdb3b74f9 /moses2
parente971f23eee8fc950ec56a3a4df0e68f281ceb8b7 (diff)
InitializeForInput()
Diffstat (limited to 'moses2')
-rw-r--r--moses2/FF/FeatureFunction.h3
-rw-r--r--moses2/FF/FeatureFunctions.cpp7
-rw-r--r--moses2/FF/FeatureFunctions.h6
-rw-r--r--moses2/ManagerBase.cpp1
-rw-r--r--moses2/ManagerBase.h2
-rw-r--r--moses2/System.cpp2
-rw-r--r--moses2/TranslationModel/MSPT/MSPT.cpp5
-rw-r--r--moses2/TranslationModel/MSPT/MSPT.h2
8 files changed, 24 insertions, 4 deletions
diff --git a/moses2/FF/FeatureFunction.h b/moses2/FF/FeatureFunction.h
index 102bda8f1..fa0f1fbe9 100644
--- a/moses2/FF/FeatureFunction.h
+++ b/moses2/FF/FeatureFunction.h
@@ -25,6 +25,7 @@ class TargetPhraseImpl;
class Scores;
class ManagerBase;
class MemPool;
+class InputType;
namespace SCFG
{
@@ -95,6 +96,8 @@ public:
const SCFG::TargetPhrases &tps, const Phrase<SCFG::Word> &sourcePhrase) const {
}
+ virtual void InitializeForInput(const InputType &input) { };
+
// clean up temporary memory, called after processing each sentence
virtual void CleanUpAfterSentenceProcessing() const {
}
diff --git a/moses2/FF/FeatureFunctions.cpp b/moses2/FF/FeatureFunctions.cpp
index 0e61fb0e4..12cdd8d24 100644
--- a/moses2/FF/FeatureFunctions.cpp
+++ b/moses2/FF/FeatureFunctions.cpp
@@ -229,6 +229,13 @@ void FeatureFunctions::EvaluateWhenAppliedBatch(const Batch &batch) const
}
}
+void FeatureFunctions::InitializeForInput(const InputType &input)
+{
+ BOOST_FOREACH(FeatureFunction *ff, m_featureFunctions) {
+ ff->InitializeForInput(input);
+ }
+}
+
void FeatureFunctions::CleanUpAfterSentenceProcessing() const
{
BOOST_FOREACH(const FeatureFunction *ff, m_featureFunctions) {
diff --git a/moses2/FF/FeatureFunctions.h b/moses2/FF/FeatureFunctions.h
index 6a3f9bb78..6714d57cc 100644
--- a/moses2/FF/FeatureFunctions.h
+++ b/moses2/FF/FeatureFunctions.h
@@ -31,6 +31,7 @@ class Scores;
class Hypothesis;
class UnknownWordPenalty;
class Weights;
+class InputType;
namespace SCFG
{
@@ -47,7 +48,7 @@ public:
FeatureFunctions(System &system);
virtual ~FeatureFunctions();
- const std::vector<const FeatureFunction*> &GetFeatureFunctions() const {
+ const std::vector<FeatureFunction*> &GetFeatureFunctions() const {
return m_featureFunctions;
}
@@ -86,12 +87,13 @@ public:
void EvaluateWhenAppliedBatch(const Batch &batch) const;
+ void InitializeForInput(const InputType &input);
void CleanUpAfterSentenceProcessing() const;
void ShowWeights(const Weights &allWeights);
protected:
- std::vector<const FeatureFunction*> m_featureFunctions;
+ std::vector<FeatureFunction*> m_featureFunctions;
std::vector<const StatefulFeatureFunction*> m_statefulFeatureFunctions;
std::vector<const FeatureFunction*> m_withPhraseTableInd;
const UnknownWordPenalty *m_unkWP;
diff --git a/moses2/ManagerBase.cpp b/moses2/ManagerBase.cpp
index f40aa7b2f..06365df54 100644
--- a/moses2/ManagerBase.cpp
+++ b/moses2/ManagerBase.cpp
@@ -30,6 +30,7 @@ ManagerBase::ManagerBase(System &sys, const TranslationTask &task,
,m_systemPool(NULL)
,m_hypoRecycle(NULL)
{
+ system.featureFunctions.InitializeForInput(*m_input);
}
ManagerBase::~ManagerBase()
diff --git a/moses2/ManagerBase.h b/moses2/ManagerBase.h
index cb8ee019c..d0740109c 100644
--- a/moses2/ManagerBase.h
+++ b/moses2/ManagerBase.h
@@ -33,7 +33,7 @@ class HypothesisBase;
class ManagerBase
{
public:
- const System &system;
+ System &system;
const TranslationTask &task;
mutable ArcLists arcLists;
diff --git a/moses2/System.cpp b/moses2/System.cpp
index fefb61ba4..91c247b75 100644
--- a/moses2/System.cpp
+++ b/moses2/System.cpp
@@ -97,7 +97,7 @@ void System::LoadWeights()
const WeightMap &allWeights = params.GetAllWeights();
// check all weights are there for all FF
- const std::vector<const FeatureFunction*> &ffs = featureFunctions.GetFeatureFunctions();
+ const std::vector<FeatureFunction*> &ffs = featureFunctions.GetFeatureFunctions();
BOOST_FOREACH(const FeatureFunction *ff, ffs) {
if (ff->IsTuneable()) {
const std::string &ffName = ff->GetName();
diff --git a/moses2/TranslationModel/MSPT/MSPT.cpp b/moses2/TranslationModel/MSPT/MSPT.cpp
index c905d5240..04a900812 100644
--- a/moses2/TranslationModel/MSPT/MSPT.cpp
+++ b/moses2/TranslationModel/MSPT/MSPT.cpp
@@ -150,6 +150,11 @@ void MSPT::Load(System &system)
*/
}
+void MSPT::InitializeForInput(const InputType &input)
+{
+ cerr << "InitializeForInput" << endl;
+}
+
TargetPhrases* MSPT::Lookup(const Manager &mgr, MemPool &pool,
InputPath &inputPath) const
{
diff --git a/moses2/TranslationModel/MSPT/MSPT.h b/moses2/TranslationModel/MSPT/MSPT.h
index d3946d353..a7fd6e2da 100644
--- a/moses2/TranslationModel/MSPT/MSPT.h
+++ b/moses2/TranslationModel/MSPT/MSPT.h
@@ -66,6 +66,8 @@ public:
const SCFG::Stacks &stacks,
SCFG::InputPath &path) const;
+ virtual void InitializeForInput(const InputType &input);
+
protected:
PBNODE *m_rootPb;
SCFGNODE *m_rootSCFG;