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>2016-06-28 12:06:53 +0300
committerHieu Hoang <hieuhoang@gmail.com>2016-06-28 12:08:30 +0300
commitaca2db894cd7180ae95836ef6baa729e75047574 (patch)
tree1062705f523e2f1033a334ee9b47aa3f78d5cb22 /moses/TranslationModel
parentaa37aba8aae23640c4849e280f6270d9da1ad554 (diff)
move Moses classes out of OnDiskPt
Diffstat (limited to 'moses/TranslationModel')
-rw-r--r--moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp13
-rw-r--r--moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp36
-rw-r--r--moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h10
3 files changed, 52 insertions, 7 deletions
diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
index 04f8db219..5a5a1368a 100644
--- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
+++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerOnDisk.cpp
@@ -251,12 +251,13 @@ void ChartRuleLookupManagerOnDisk::GetChartRuleCollection(
std::vector<float> weightT = staticData.GetWeights(&m_dictionary);
targetPhraseCollection
- = tpcollBerkeleyDb->ConvertToMoses(m_inputFactorsVec
- ,m_outputFactorsVec
- ,m_dictionary
- ,weightT
- ,m_dbWrapper.GetVocab()
- ,true);
+ = m_dictionary.ConvertToMoses(tpcollBerkeleyDb
+ ,m_inputFactorsVec
+ ,m_outputFactorsVec
+ ,m_dictionary
+ ,weightT
+ ,m_dbWrapper.GetVocab()
+ ,true);
tpcollBerkeleyDb.reset();
m_cache[tpCollFilePos] = targetPhraseCollection;
diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
index adb3f36c1..9ca2c9b0b 100644
--- a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
+++ b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp
@@ -206,7 +206,7 @@ GetTargetPhraseCollectionNonCache(const OnDiskPt::PhraseNode *ptNode) const
OnDiskPt::TargetPhraseCollection::shared_ptr targetPhrasesOnDisk
= ptNode->GetTargetPhraseCollection(m_tableLimit, wrapper);
TargetPhraseCollection::shared_ptr targetPhrases
- = targetPhrasesOnDisk->ConvertToMoses(m_input, m_output, *this,
+ = ConvertToMoses(targetPhrasesOnDisk, m_input, m_output, *this,
weightT, vocab, false);
// delete targetPhrasesOnDisk;
@@ -214,6 +214,40 @@ GetTargetPhraseCollectionNonCache(const OnDiskPt::PhraseNode *ptNode) const
return targetPhrases;
}
+Moses::TargetPhraseCollection::shared_ptr
+PhraseDictionaryOnDisk::ConvertToMoses(
+ const OnDiskPt::TargetPhraseCollection::shared_ptr targetPhrasesOnDisk
+ , const std::vector<Moses::FactorType> &inputFactors
+ , const std::vector<Moses::FactorType> &outputFactors
+ , const Moses::PhraseDictionary &phraseDict
+ , const std::vector<float> &weightT
+ , OnDiskPt::Vocab &vocab
+ , bool isSyntax) const
+{
+ Moses::TargetPhraseCollection::shared_ptr ret;
+ ret.reset(new Moses::TargetPhraseCollection);
+
+ for (size_t i = 0; i < targetPhrasesOnDisk->GetSize(); ++i) {
+ const OnDiskPt::TargetPhrase &tp = targetPhrasesOnDisk->GetTargetPhrase(i);
+ Moses::TargetPhrase *mosesPhrase
+ = tp.ConvertToMoses(inputFactors, outputFactors, vocab,
+ phraseDict, weightT, isSyntax);
+
+ /*
+ // debugging output
+ stringstream strme;
+ strme << filePath << " " << *mosesPhrase;
+ mosesPhrase->SetDebugOutput(strme.str());
+ */
+
+ ret->Add(mosesPhrase);
+ }
+
+ ret->Sort(true, phraseDict.GetTableLimit());
+
+ return ret;
+}
+
void PhraseDictionaryOnDisk::SetParameter(const std::string& key, const std::string& value)
{
if (key == "max-span-default") {
diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
index 1bd357d05..7a0c06c4a 100644
--- a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
+++ b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.h
@@ -84,6 +84,16 @@ public:
TargetPhraseCollection::shared_ptr
GetTargetPhraseCollectionNonCache(const OnDiskPt::PhraseNode *ptNode) const;
+ Moses::TargetPhraseCollection::shared_ptr
+ ConvertToMoses(
+ const OnDiskPt::TargetPhraseCollection::shared_ptr targetPhrasesOnDisk
+ , const std::vector<Moses::FactorType> &inputFactors
+ , const std::vector<Moses::FactorType> &outputFactors
+ , const Moses::PhraseDictionary &phraseDict
+ , const std::vector<float> &weightT
+ , OnDiskPt::Vocab &vocab
+ , bool isSyntax) const;
+
void SetParameter(const std::string& key, const std::string& value);
};