diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2016-09-30 19:54:47 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2016-09-30 19:54:47 +0300 |
commit | 22423d45e2363e44c6f60189e9803d97c024752c (patch) | |
tree | 2de1674460c689401f1019230804d1bf48c21e94 | |
parent | 792b25cbbd404d49298c25a43d7fdb4c4cdd481f (diff) |
lookup in size order for compact pt
5 files changed, 29 insertions, 0 deletions
diff --git a/contrib/moses2/TranslationModel/CompactPT/PhraseDecoder.cpp b/contrib/moses2/TranslationModel/CompactPT/PhraseDecoder.cpp index 4ff4375cd..e08ebe372 100644 --- a/contrib/moses2/TranslationModel/CompactPT/PhraseDecoder.cpp +++ b/contrib/moses2/TranslationModel/CompactPT/PhraseDecoder.cpp @@ -224,6 +224,9 @@ TargetPhraseVectorPtr PhraseDecoder::CreateTargetPhraseCollection( // Retrieve source phrase identifier std::string sourcePhraseString = sourcePhrase.GetString(*m_input); size_t sourcePhraseId = m_phraseDictionary.m_hash[MakeSourceKey(sourcePhraseString)]; + cerr << "sourcePhraseString=" << sourcePhraseString << " " + << sourcePhraseId + << endl; if(sourcePhraseId != m_phraseDictionary.m_hash.GetSize()) { // Retrieve compressed and encoded target phrase collection diff --git a/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp b/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp index bdb357234..43fe34ed0 100644 --- a/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp +++ b/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp @@ -6,6 +6,7 @@ #include "../../PhraseBased/Manager.h" #include "../../PhraseBased/TargetPhrases.h" #include "../../PhraseBased/TargetPhraseImpl.h" +#include "../../PhraseBased/Sentence.h" using namespace std; using namespace boost::algorithm; @@ -78,12 +79,31 @@ void PhraseTableCompact::SetParameter(const std::string& key, const std::string& } // pb +void PhraseTableCompact::Lookup(const Manager &mgr, InputPathsBase &inputPaths) const +{ + size_t inputSize = static_cast<const Sentence&>(mgr.GetInput()).GetSize(); + InputPaths &inputPathsCast = static_cast<InputPaths&>(inputPaths); + + for (size_t i = 0; i < inputSize; ++i) { + for (size_t startPos = 0; startPos < inputSize; ++startPos) { + size_t endPos = startPos + i; + if (endPos >= inputSize) { + break; + } + const InputPath *path = inputPathsCast.GetMatrix().GetValue(startPos, i); + cerr << "path=" << path->Debug(mgr.system) << endl; + } + } +} + TargetPhrases *PhraseTableCompact::Lookup(const Manager &mgr, MemPool &pool, InputPath &inputPath) const { TargetPhrases *ret = NULL; const Phrase<Word> &sourcePhrase = inputPath.subPhrase; + cerr << "sourcePhrase=" << sourcePhrase.Debug(mgr.system) << endl; + // There is no souch source phrase if source phrase is longer than longest // observed source phrase during compilation if(sourcePhrase.GetSize() > m_phraseDecoder->GetMaxSourcePhraseLength()) diff --git a/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.h b/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.h index 33d6dc178..4d1352bb1 100644 --- a/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.h +++ b/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.h @@ -23,6 +23,8 @@ public: const SCFG::Manager &mgr, SCFG::InputPath &path) const; + virtual void Lookup(const Manager &mgr, InputPathsBase &inputPaths) const; + virtual void Lookup( MemPool &pool, const SCFG::Manager &mgr, diff --git a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp index 287f1da32..10ef5f99c 100644 --- a/moses/TranslationModel/CompactPT/PhraseDecoder.cpp +++ b/moses/TranslationModel/CompactPT/PhraseDecoder.cpp @@ -219,6 +219,9 @@ TargetPhraseVectorPtr PhraseDecoder::CreateTargetPhraseCollection(const Phrase & // Retrieve source phrase identifier std::string sourcePhraseString = sourcePhrase.GetStringRep(*m_input); size_t sourcePhraseId = m_phraseDictionary.m_hash[MakeSourceKey(sourcePhraseString)]; + cerr << "sourcePhraseString=" << sourcePhraseString << " " + << sourcePhraseId + << endl; if(sourcePhraseId != m_phraseDictionary.m_hash.GetSize()) { // Retrieve compressed and encoded target phrase collection diff --git a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp index 28850ccaa..a7c41cddf 100644 --- a/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp +++ b/moses/TranslationModel/CompactPT/PhraseDictionaryCompact.cpp @@ -101,6 +101,7 @@ TargetPhraseCollection::shared_ptr PhraseDictionaryCompact:: GetTargetPhraseCollectionNonCacheLEGACY(const Phrase &sourcePhrase) const { + cerr << "sourcePhrase=" << sourcePhrase << endl; TargetPhraseCollection::shared_ptr ret; // There is no souch source phrase if source phrase is longer than longest |