From 4da9a8842bfab8e9780721b38324c7002476e401 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Mon, 15 Jul 2013 16:16:51 +0100 Subject: [PATCH 1/4] Updated PCL --- contrib/arrow-pipelines/python/pcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/arrow-pipelines/python/pcl b/contrib/arrow-pipelines/python/pcl index 131518520..7b4b59da5 160000 --- a/contrib/arrow-pipelines/python/pcl +++ b/contrib/arrow-pipelines/python/pcl @@ -1 +1 @@ -Subproject commit 1315185203a90b6f80acf2e47b4ea85b420b0d4c +Subproject commit 7b4b59da587ea3e1ad20043a528ae26dd75912e5 From 1883db3f420bd9e4cdc798218809b49f1000f51e Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Tue, 16 Jul 2013 10:06:19 +0100 Subject: [PATCH 2/4] Updated PCL --- contrib/arrow-pipelines/python/pcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/arrow-pipelines/python/pcl b/contrib/arrow-pipelines/python/pcl index 7b4b59da5..b4334b8f2 160000 --- a/contrib/arrow-pipelines/python/pcl +++ b/contrib/arrow-pipelines/python/pcl @@ -1 +1 @@ -Subproject commit 7b4b59da587ea3e1ad20043a528ae26dd75912e5 +Subproject commit b4334b8f276d401c38b1163c4c33ad6b840e28be From e1a86bd9c900a4ee6b30f07dec68e86ce1f62e4c Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 16 Jul 2013 16:30:54 +0100 Subject: [PATCH 3/4] sometimes target phrase collection can have 0 phrases --- .../TranslationModel/PhraseDictionaryMultiModelCounts.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp b/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp index 1ae90cd3c..39ed47c2e 100644 --- a/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp +++ b/moses/TranslationModel/PhraseDictionaryMultiModelCounts.cpp @@ -223,7 +223,6 @@ void PhraseDictionaryMultiModelCounts::Load() const TargetPhraseCollection *PhraseDictionaryMultiModelCounts::GetTargetPhraseCollection(const Phrase& src) const { - vector > multimodelweights; bool normalize; normalize = (m_mode == "interpolate") ? true : false; @@ -346,11 +345,11 @@ float PhraseDictionaryMultiModelCounts::GetTargetCount(const Phrase &target, siz { const PhraseDictionary &pd = *m_inverse_pd[modelIndex]; - TargetPhraseCollection *ret_raw = (TargetPhraseCollection*) pd.GetTargetPhraseCollection(target); + const TargetPhraseCollection *ret_raw = pd.GetTargetPhraseCollection(target); // in inverse mode, we want the first score of the first phrase pair (note: if we were to work with truly symmetric models, it would be the third score) - if (ret_raw != NULL) { - TargetPhrase * targetPhrase = *(ret_raw->begin()); + if (ret_raw && ret_raw->GetSize() > 0) { + const TargetPhrase * targetPhrase = *(ret_raw->begin()); return UntransformScore(targetPhrase->GetScoreBreakdown().GetScoresForProducer(&pd)[0]); } From f3e0fd2dd4f9e3b54d32f6d2351972429fbd54a5 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 16 Jul 2013 16:55:56 +0100 Subject: [PATCH 4/4] finished converting TargetPhraseCollection* to TargetPhraseCollection --- .../CYKPlusParser/ChartRuleLookupManagerMemory.cpp | 6 ++---- .../ChartRuleLookupManagerMemoryPerSentence.cpp | 6 ++---- moses/TranslationModel/PhraseDictionaryMemory.cpp | 4 ++-- moses/TranslationModel/PhraseDictionaryNodeMemory.h | 6 +++--- .../RuleTable/PhraseDictionaryFuzzyMatch.cpp | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp index b80d52353..e6fed90e5 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemory.cpp @@ -154,12 +154,10 @@ void ChartRuleLookupManagerMemory::GetChartRuleCollection( const PhraseDictionaryNodeMemory &node = dottedRule.GetLastNode(); // look up target sides - const TargetPhraseCollection *tpc = node.GetTargetPhraseCollection(); + const TargetPhraseCollection &tpc = node.GetTargetPhraseCollection(); // add the fully expanded rule (with lexical target side) - if (tpc != NULL) { - AddCompletedRule(dottedRule, *tpc, range, outColl); - } + AddCompletedRule(dottedRule, tpc, range, outColl); } dottedRuleCol.Clear(relEndPos+1); diff --git a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp index 86cd8c19f..00d7f323c 100644 --- a/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp +++ b/moses/TranslationModel/CYKPlusParser/ChartRuleLookupManagerMemoryPerSentence.cpp @@ -153,12 +153,10 @@ void ChartRuleLookupManagerMemoryPerSentence::GetChartRuleCollection( const PhraseDictionaryNodeMemory &node = dottedRule.GetLastNode(); // look up target sides - const TargetPhraseCollection *tpc = node.GetTargetPhraseCollection(); + const TargetPhraseCollection &tpc = node.GetTargetPhraseCollection(); // add the fully expanded rule (with lexical target side) - if (tpc != NULL) { - AddCompletedRule(dottedRule, *tpc, range, outColl); - } + AddCompletedRule(dottedRule, tpc, range, outColl); } dottedRuleCol.Clear(relEndPos+1); diff --git a/moses/TranslationModel/PhraseDictionaryMemory.cpp b/moses/TranslationModel/PhraseDictionaryMemory.cpp index 2caaa5aa9..97bb53e2b 100644 --- a/moses/TranslationModel/PhraseDictionaryMemory.cpp +++ b/moses/TranslationModel/PhraseDictionaryMemory.cpp @@ -51,7 +51,7 @@ TargetPhraseCollection &PhraseDictionaryMemory::GetOrCreateTargetPhraseCollectio , const Word *sourceLHS) { PhraseDictionaryNodeMemory &currNode = GetOrCreateNode(source, target, sourceLHS); - return currNode.GetOrCreateTargetPhraseCollection(); + return currNode.GetTargetPhraseCollection(); } const TargetPhraseCollection *PhraseDictionaryMemory::GetTargetPhraseCollection(const Phrase& sourceOrig) const @@ -70,7 +70,7 @@ const TargetPhraseCollection *PhraseDictionaryMemory::GetTargetPhraseCollection( return NULL; } - return currNode->GetTargetPhraseCollection(); + return &currNode->GetTargetPhraseCollection(); } PhraseDictionaryNodeMemory &PhraseDictionaryMemory::GetOrCreateNode(const Phrase &source diff --git a/moses/TranslationModel/PhraseDictionaryNodeMemory.h b/moses/TranslationModel/PhraseDictionaryNodeMemory.h index 563acdd17..c643bd5fc 100644 --- a/moses/TranslationModel/PhraseDictionaryNodeMemory.h +++ b/moses/TranslationModel/PhraseDictionaryNodeMemory.h @@ -133,10 +133,10 @@ public: const PhraseDictionaryNodeMemory *GetChild(const Word &sourceTerm) const; const PhraseDictionaryNodeMemory *GetChild(const Word &sourceNonTerm, const Word &targetNonTerm) const; - const TargetPhraseCollection *GetTargetPhraseCollection() const { - return &m_targetPhraseCollection; + const TargetPhraseCollection &GetTargetPhraseCollection() const { + return m_targetPhraseCollection; } - TargetPhraseCollection &GetOrCreateTargetPhraseCollection() { + TargetPhraseCollection &GetTargetPhraseCollection() { return m_targetPhraseCollection; } diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp b/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp index bba5f9a85..a14d4922b 100644 --- a/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp +++ b/moses/TranslationModel/RuleTable/PhraseDictionaryFuzzyMatch.cpp @@ -263,7 +263,7 @@ TargetPhraseCollection &PhraseDictionaryFuzzyMatch::GetOrCreateTargetPhraseColle , const Word *sourceLHS) { PhraseDictionaryNodeMemory &currNode = GetOrCreateNode(rootNode, source, target, sourceLHS); - return currNode.GetOrCreateTargetPhraseCollection(); + return currNode.GetTargetPhraseCollection(); } PhraseDictionaryNodeMemory &PhraseDictionaryFuzzyMatch::GetOrCreateNode(PhraseDictionaryNodeMemory &rootNode