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 <hieuhoang@gmail.com>2020-10-05 22:47:13 +0300
committerHieu Hoang <hieuhoang@gmail.com>2020-10-05 22:47:13 +0300
commit83dd5fb7ff999199efdeada5e93e67ad12bff548 (patch)
treea4baa84527af1e61fb70181c7077b483e9cd8d51
parentb8ae6d58afbd17a4e9b11d3c3f6fc8307d3f16d6 (diff)
MSPT works
-rw-r--r--moses2/PhraseBased/SentenceWithCandidates.cpp16
-rw-r--r--moses2/TranslationModel/MSPT/MSPT.cpp29
-rw-r--r--moses2/TranslationModel/PhraseTable.cpp8
3 files changed, 25 insertions, 28 deletions
diff --git a/moses2/PhraseBased/SentenceWithCandidates.cpp b/moses2/PhraseBased/SentenceWithCandidates.cpp
index 6e4190a4e..b13a648ee 100644
--- a/moses2/PhraseBased/SentenceWithCandidates.cpp
+++ b/moses2/PhraseBased/SentenceWithCandidates.cpp
@@ -38,10 +38,10 @@ SentenceWithCandidates *SentenceWithCandidates::CreateFromString(MemPool &pool,
input_parts.push_back(copy_range<std::string>(*It));
}
- cerr << "Number of subparts: " << input_parts.size() << endl;
+ //cerr << "Number of subparts: " << input_parts.size() << endl;
if (input_parts.size() ==2 ) {
- cerr << "correct number of parts" << endl ;
+ //cerr << "correct number of parts" << endl ;
} else {
// TODO: how to handle wrong input format
cerr << "INCORRECT number of parts" << endl ;
@@ -50,8 +50,8 @@ SentenceWithCandidates *SentenceWithCandidates::CreateFromString(MemPool &pool,
trim(input_parts[0]);
trim(input_parts[1]);
- cerr << "Input String: " << input_parts[0] << endl ;
- cerr << "Phrase Table: " << input_parts[1] << endl ;
+ //cerr << "Input String: " << input_parts[0] << endl ;
+ //cerr << "Phrase Table: " << input_parts[1] << endl ;
///// Process the text part of the input
const string partstr = input_parts[0];
@@ -72,7 +72,7 @@ SentenceWithCandidates *SentenceWithCandidates::CreateFromString(MemPool &pool,
ret->m_phraseTableString = replace_all_copy(input_parts[1],PT_LINE_DELIM,"\n");
// ret->m_phraseTableString="constant phrase table";
// cerr << "Extracted Phrase Table String: " << ret->m_phraseTableString << endl;
- cerr << "Extracted Phrase Table String: " << ret->getPhraseTableString() << endl;
+ //cerr << "Extracted Phrase Table String: " << ret->getPhraseTableString() << endl;
return ret;
}
@@ -80,17 +80,17 @@ SentenceWithCandidates *SentenceWithCandidates::CreateFromString(MemPool &pool,
SentenceWithCandidates::SentenceWithCandidates(MemPool &pool, size_t size)
:Sentence(pool, size)
{
- cerr << "SentenceWithCandidates::SentenceWithCandidates" << endl;
+ //cerr << "SentenceWithCandidates::SentenceWithCandidates" << endl;
}
SentenceWithCandidates::~SentenceWithCandidates()
{
- cerr << "SentenceWithCandidates::~SentenceWithCandidates" << endl;
+ //cerr << "SentenceWithCandidates::~SentenceWithCandidates" << endl;
}
std::string SentenceWithCandidates::Debug(const System &system) const
{
- cerr << "SentenceWithCandidates::Debug" << endl;
+ return "SentenceWithCandidates::Debug";
}
} /* namespace Moses2 */
diff --git a/moses2/TranslationModel/MSPT/MSPT.cpp b/moses2/TranslationModel/MSPT/MSPT.cpp
index d72d0b395..0c20b2669 100644
--- a/moses2/TranslationModel/MSPT/MSPT.cpp
+++ b/moses2/TranslationModel/MSPT/MSPT.cpp
@@ -30,6 +30,7 @@
#include "../../SCFG/Manager.h"
#include "../../PhraseBased/SentenceWithCandidates.h"
+#include "../../PhraseBased/Manager.h"
using namespace std;
@@ -55,7 +56,7 @@ MSPT::~MSPT()
void MSPT::CreatePTForInput(const System &system, string phraseTableString)
{
- cerr << "In CreatePTForInput" << endl << flush;
+ //cerr << "In CreatePTForInput" << endl << flush;
FactorCollection &vocab = system.GetVocab();
MemPool &systemPool = system.GetSystemPool();
@@ -105,7 +106,7 @@ void MSPT::CreatePTForInput(const System &system, string phraseTableString)
system.featureFunctions.EvaluateInIsolation(systemPool, system, *source,
*target);
- //cerr << "EvaluateInIsolation:" << *target << endl;
+ //cerr << "EvaluateInIsolation:" << target->Debug(system) << endl;
m_rootPb->AddRule(m_input, *source, target);
//cerr << "target=" << target->Debug(system) << endl;
@@ -158,27 +159,29 @@ void MSPT::CreatePTForInput(const System &system, string phraseTableString)
void MSPT::InitializeForInput(const System &system, const InputType &input)
{
- cerr << "InitializeForInput MSPT" << endl;
- cerr << input.Debug(system) << endl << flush;
- cerr << "HH1" << endl << flush;
+ //cerr << "InitializeForInput MSPT" << endl;
+ //cerr << input.Debug(system) << endl;
+ //cerr << "HH1" << endl << flush;
// downcast to SentenceWithCandidates
- //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;
-
- cerr << "Hardcoding sample PhraseTableString" << endl << flush;
- string phraseTableString="a ||| x ||| 0.4 $$$ a ||| y ||| 0.6 $$$ b ||| y ||| 0.1 $$$ b ||| z ||| 0.9";
- CreatePTForInput(system,phraseTableString);
+ 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 << flush;
+ //cerr << "HH2" << endl << flush;
+ CreatePTForInput(system, inputObj.getPhraseTableString());
+ //cerr << "HH3" << endl << flush;
}
TargetPhrases* MSPT::Lookup(const Manager &mgr, MemPool &pool,
InputPath &inputPath) const
{
+ //cerr << "MSPT::Lookup inputPath:" << inputPath.Debug(mgr.system) << endl;
const SubPhrase<Moses2::Word> &phrase = inputPath.subPhrase;
TargetPhrases *tps = m_rootPb->Find(m_input, phrase);
+ //cerr << "MSPT::Lookup tps:" << tps->Debug(mgr.system) << endl;
+ //cerr << "MSPT::Lookup done" << endl;
return tps;
}
diff --git a/moses2/TranslationModel/PhraseTable.cpp b/moses2/TranslationModel/PhraseTable.cpp
index fef6771d6..1f87b8040 100644
--- a/moses2/TranslationModel/PhraseTable.cpp
+++ b/moses2/TranslationModel/PhraseTable.cpp
@@ -80,13 +80,7 @@ void PhraseTable::Lookup(const Manager &mgr, InputPathsBase &inputPaths) const
if (SatisfyBackoff(mgr, *path)) {
TargetPhrases *tpsPtr = Lookup(mgr, mgr.GetPool(), *path);
- /*
- cerr << "tpsPtr=" << tpsPtr << " ";
- if (tps.get()) {
- cerr << tps.get()->GetSize();
- }
- cerr << endl;
- */
+ //cerr << "tpsPtr=" << tpsPtr << endl;
path->AddTargetPhrases(*this, tpsPtr);
}