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:
authorAnoop Kunchukuttan <anoop.kunchukuttan@gmail.com>2020-10-05 12:54:23 +0300
committerAnoop Kunchukuttan <anoop.kunchukuttan@gmail.com>2020-10-05 12:54:23 +0300
commita34623140a2d9a2793ab91337d8f3883382c2b20 (patch)
tree610ff6d4cafdebbebc72e0c2661009b6dbd7e0c4
parent6801d65c58c8d47e7f9424fe6c842fc046b84d62 (diff)
parent5e38a00a5fc27291f45adecfadf006818c892306 (diff)
Merge branch 'master'
-rw-r--r--moses2/FF/FeatureFunction.h4
-rw-r--r--moses2/FF/FeatureFunctions.cpp4
-rw-r--r--moses2/InputType.cpp8
-rw-r--r--moses2/InputType.h2
-rw-r--r--moses2/ManagerBase.cpp2
-rw-r--r--moses2/PhraseBased/Manager.cpp2
-rw-r--r--moses2/PhraseBased/SentenceWithCandidates.cpp16
-rw-r--r--moses2/PhraseBased/SentenceWithCandidates.h9
-rw-r--r--moses2/TranslationModel/MSPT/MSPT.cpp12
-rw-r--r--moses2/TranslationModel/MSPT/MSPT.h2
10 files changed, 45 insertions, 16 deletions
diff --git a/moses2/FF/FeatureFunction.h b/moses2/FF/FeatureFunction.h
index 34742efb1..828a712b9 100644
--- a/moses2/FF/FeatureFunction.h
+++ b/moses2/FF/FeatureFunction.h
@@ -96,10 +96,10 @@ public:
const SCFG::TargetPhrases &tps, const Phrase<SCFG::Word> &sourcePhrase) const {
}
- virtual void InitializeForInput(const InputType &input) { };
+ virtual void InitializeForInput(const System &system, const InputType &input) { };
// clean up temporary memory, called after processing each sentence
- virtual void CleanUpAfterSentenceProcessing(const InputType &input) const {
+ virtual void CleanUpAfterSentenceProcessing(const System &system, const InputType &input) const {
}
protected:
diff --git a/moses2/FF/FeatureFunctions.cpp b/moses2/FF/FeatureFunctions.cpp
index efe018b7b..39e2436b6 100644
--- a/moses2/FF/FeatureFunctions.cpp
+++ b/moses2/FF/FeatureFunctions.cpp
@@ -232,14 +232,14 @@ void FeatureFunctions::EvaluateWhenAppliedBatch(const Batch &batch) const
void FeatureFunctions::InitializeForInput(const InputType &input)
{
BOOST_FOREACH(FeatureFunction *ff, m_featureFunctions) {
- ff->InitializeForInput(input);
+ ff->InitializeForInput(m_system, input);
}
}
void FeatureFunctions::CleanUpAfterSentenceProcessing(const InputType &input) const
{
BOOST_FOREACH(const FeatureFunction *ff, m_featureFunctions) {
- ff->CleanUpAfterSentenceProcessing(input);
+ ff->CleanUpAfterSentenceProcessing(m_system, input);
}
}
diff --git a/moses2/InputType.cpp b/moses2/InputType.cpp
index 60664a85b..af5b61ff9 100644
--- a/moses2/InputType.cpp
+++ b/moses2/InputType.cpp
@@ -7,6 +7,9 @@
#include "InputType.h"
#include "System.h"
+#include <iostream>
+
+using namespace std;
namespace Moses2
{
@@ -89,4 +92,9 @@ bool InputType::XmlOverlap(size_t startPos, size_t endPos) const
return false;
}
+std::string InputType::Debug(const System &system) const
+{
+ cerr << "InputType::Debug" << endl;
+}
+
} /* namespace Moses2 */
diff --git a/moses2/InputType.h b/moses2/InputType.h
index 8813bc484..b4f901ac6 100644
--- a/moses2/InputType.h
+++ b/moses2/InputType.h
@@ -73,6 +73,8 @@ public:
//! Returns true if there were any XML tags parsed that at least partially covered the range passed
bool XmlOverlap(size_t startPos, size_t endPos) const;
+ virtual std::string Debug(const System &system) const;
+
protected:
ReorderingConstraint m_reorderingConstraint; /**< limits on reordering specified either by "-mp" switch or xml tags */
Vector<const XMLOption*> m_xmlOptions;
diff --git a/moses2/ManagerBase.cpp b/moses2/ManagerBase.cpp
index 0ab60f9f1..41d3a0394 100644
--- a/moses2/ManagerBase.cpp
+++ b/moses2/ManagerBase.cpp
@@ -29,8 +29,8 @@ ManagerBase::ManagerBase(System &sys, const TranslationTask &task,
,m_pool(NULL)
,m_systemPool(NULL)
,m_hypoRecycle(NULL)
+ ,m_input(NULL)
{
- system.featureFunctions.InitializeForInput(*m_input);
}
ManagerBase::~ManagerBase()
diff --git a/moses2/PhraseBased/Manager.cpp b/moses2/PhraseBased/Manager.cpp
index bb3c130c5..cce30efb1 100644
--- a/moses2/PhraseBased/Manager.cpp
+++ b/moses2/PhraseBased/Manager.cpp
@@ -62,6 +62,8 @@ void Manager::Init()
FactorCollection &vocab = system.GetVocab();
//TODO: need option to choose Sentence vs SentenceWithCandidates
m_input = Moses2::SentenceWithCandidates::CreateFromString(GetPool(), vocab, system, m_inputStr);
+ //cerr << "Manager::Init: " << m_input->Debug(system) << endl << flush;
+ system.featureFunctions.InitializeForInput(*m_input);
m_bitmaps = new Bitmaps(GetPool());
diff --git a/moses2/PhraseBased/SentenceWithCandidates.cpp b/moses2/PhraseBased/SentenceWithCandidates.cpp
index cb96a9d92..6e4190a4e 100644
--- a/moses2/PhraseBased/SentenceWithCandidates.cpp
+++ b/moses2/PhraseBased/SentenceWithCandidates.cpp
@@ -77,5 +77,21 @@ SentenceWithCandidates *SentenceWithCandidates::CreateFromString(MemPool &pool,
return ret;
}
+SentenceWithCandidates::SentenceWithCandidates(MemPool &pool, size_t size)
+:Sentence(pool, size)
+{
+ cerr << "SentenceWithCandidates::SentenceWithCandidates" << endl;
+}
+
+SentenceWithCandidates::~SentenceWithCandidates()
+{
+ cerr << "SentenceWithCandidates::~SentenceWithCandidates" << endl;
+}
+
+std::string SentenceWithCandidates::Debug(const System &system) const
+{
+ cerr << "SentenceWithCandidates::Debug" << endl;
+}
+
} /* namespace Moses2 */
diff --git a/moses2/PhraseBased/SentenceWithCandidates.h b/moses2/PhraseBased/SentenceWithCandidates.h
index 5cc34590d..fb550d577 100644
--- a/moses2/PhraseBased/SentenceWithCandidates.h
+++ b/moses2/PhraseBased/SentenceWithCandidates.h
@@ -29,13 +29,10 @@ public:
static SentenceWithCandidates *CreateFromString(MemPool &pool, FactorCollection &vocab,
const System &system, const std::string &str);
- SentenceWithCandidates(MemPool &pool, size_t size)
- :Sentence(pool, size)
- {}
-
- virtual ~SentenceWithCandidates()
- {}
+ SentenceWithCandidates(MemPool &pool, size_t size);
+ virtual ~SentenceWithCandidates();
+ virtual std::string Debug(const System &system) const;
std::string virtual getPhraseTableString() const{
return m_phraseTableString;
}
diff --git a/moses2/TranslationModel/MSPT/MSPT.cpp b/moses2/TranslationModel/MSPT/MSPT.cpp
index 529efbb69..90feb3489 100644
--- a/moses2/TranslationModel/MSPT/MSPT.cpp
+++ b/moses2/TranslationModel/MSPT/MSPT.cpp
@@ -29,6 +29,7 @@
#include "../../SCFG/Stacks.h"
#include "../../SCFG/Manager.h"
+#include "../../PhraseBased/SentenceWithCandidates.h"
using namespace std;
@@ -153,13 +154,16 @@ MSPT::~MSPT()
// }
-void MSPT::InitializeForInput(const InputType &input)
+void MSPT::InitializeForInput(const System &system, const InputType &input)
{
cerr << "InitializeForInput MSPT" << endl;
-
+ cerr << input.Debug(system) << endl << flush;
+ cerr << "HH1" << endl << flush;
+
// downcast to SentenceWithCandidates
- const SentenceWithCandidates& inputObj = dynamic_cast<const SentenceWithCandidates&>(input);
- cerr << "Casting done." << endl;
+ //const SentenceWithCandidates &inputObj = static_cast<const SentenceWithCandidates&>(input);
+ const SentenceWithCandidates &inputObj = dynamic_cast<const SentenceWithCandidates&>(input);
+ cerr << "Casting done." << endl << flush;
cerr << "PhraseTableString member: " << inputObj.getPhraseTableString() << endl;
}
diff --git a/moses2/TranslationModel/MSPT/MSPT.h b/moses2/TranslationModel/MSPT/MSPT.h
index 165565791..b3ff99c91 100644
--- a/moses2/TranslationModel/MSPT/MSPT.h
+++ b/moses2/TranslationModel/MSPT/MSPT.h
@@ -65,7 +65,7 @@ public:
const SCFG::Stacks &stacks,
SCFG::InputPath &path) const;
- virtual void InitializeForInput(const InputType &input);
+ virtual void InitializeForInput(const System &system, const InputType &input);
protected:
PBNODE *m_rootPb;