diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2016-09-29 23:06:27 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2016-09-29 23:06:27 +0300 |
commit | 0f536c26024eb2a3a17d428f23b9bd73bc46aa49 (patch) | |
tree | 3bf94a1d14a0cc14d09e427a332c984400967213 | |
parent | d60722976aef9f32b63514e2d30639cf961c1056 (diff) |
import load
-rw-r--r-- | contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp | 36 | ||||
-rw-r--r-- | contrib/moses2/TranslationModel/PhraseTable.cpp | 23 |
2 files changed, 45 insertions, 14 deletions
diff --git a/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp b/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp index 38e370173..4a3337b81 100644 --- a/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp +++ b/contrib/moses2/TranslationModel/CompactPT/PhraseTableCompact.cpp @@ -33,10 +33,42 @@ void PhraseTableCompact::Load(System &system) if (!ends_with(tFilePath, suffix)) tFilePath += suffix; if (!FileExists(tFilePath)) throw runtime_error("Error: File " + tFilePath + " does not exist."); + cerr << "tFilePath=" << tFilePath << endl; - //m_phraseDecoder - //= new PhraseDecoder(*this, &m_input, &m_output, GetNumScores()); + m_phraseDecoder + = new PhraseDecoder(*this, &m_input, &m_output, GetNumScores()); + cerr << "m_phraseDecoder=" << m_phraseDecoder << endl; + std::FILE* pFile = std::fopen(tFilePath.c_str() , "r"); + cerr << "pFile=" << pFile << endl; + + size_t indexSize; + //if(m_inMemory) + // Load source phrase index into memory + indexSize = m_hash.Load(pFile); + cerr << "indexSize=" << indexSize << endl; + // else + // Keep source phrase index on disk + //indexSize = m_hash.LoadIndex(pFile); + + size_t coderSize = m_phraseDecoder->Load(pFile); + cerr << "coderSize=" << coderSize << endl; + + size_t phraseSize; + if(m_inMemory) { + // Load target phrase collections into memory + cerr << "m_inMemory=" << phraseSize << endl; + phraseSize = m_targetPhrasesMemory.load(pFile, false); + } + else { + // Keep target phrase collections on disk + cerr << "not m_inMemory=" << phraseSize << endl; + phraseSize = m_targetPhrasesMapped.load(pFile, true); + } + cerr << "phraseSize=" << phraseSize << endl; + + UTIL_THROW_IF2(indexSize == 0 || coderSize == 0 || phraseSize == 0, + "Not successfully loaded"); } void PhraseTableCompact::SetParameter(const std::string& key, const std::string& value) diff --git a/contrib/moses2/TranslationModel/PhraseTable.cpp b/contrib/moses2/TranslationModel/PhraseTable.cpp index ca3c94521..8cb60574a 100644 --- a/contrib/moses2/TranslationModel/PhraseTable.cpp +++ b/contrib/moses2/TranslationModel/PhraseTable.cpp @@ -85,20 +85,19 @@ void PhraseTable::Lookup(const Manager &mgr, InputPathsBase &inputPaths) const { BOOST_FOREACH(InputPathBase *pathBase, inputPaths){ InputPath *path = static_cast<InputPath*>(pathBase); + cerr << "path=" << path->range << " "; if (SatisfyBackoff(mgr, *path)) { - TargetPhrases *tpsPtr = tpsPtr = Lookup(mgr, mgr.GetPool(), *path); - - /* - cerr << "path=" << path.GetRange() << " "; - cerr << "tps=" << tps << " "; - if (tps.get()) { - cerr << tps.get()->GetSize(); - } - cerr << endl; - */ - - path->AddTargetPhrases(*this, tpsPtr); + TargetPhrases *tpsPtr = Lookup(mgr, mgr.GetPool(), *path); + cerr << "tpsPtr=" << tpsPtr << " "; + /* + if (tps.get()) { + cerr << tps.get()->GetSize(); + } + cerr << endl; + */ + + path->AddTargetPhrases(*this, tpsPtr); } } |