From 743d5414e9ea1c6e623b9cc4fa4c5dc453d9bfed Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Mon, 24 Oct 2011 15:21:28 +0700 Subject: [PATCH 1/4] xcode --- kenlm/kenlm.xcodeproj/project.pbxproj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kenlm/kenlm.xcodeproj/project.pbxproj b/kenlm/kenlm.xcodeproj/project.pbxproj index 7f1b228f6..8a60136ed 100644 --- a/kenlm/kenlm.xcodeproj/project.pbxproj +++ b/kenlm/kenlm.xcodeproj/project.pbxproj @@ -426,8 +426,7 @@ ); HEADER_SEARCH_PATHS = ( /opt/local/include/, - /Users/hieuhoang/workspace/sourceforge/trunk/kenlm, - /usr/local/include, + ../kenlm, ../srilm/include, ); INSTALL_PATH = /usr/local/lib; @@ -447,8 +446,7 @@ ); HEADER_SEARCH_PATHS = ( /opt/local/include/, - /Users/hieuhoang/workspace/sourceforge/trunk/kenlm, - /usr/local/include, + ../kenlm, ../srilm/include, ); INSTALL_PATH = /usr/local/lib; From 82e2e094ff344dd4b846ed382dda4d4d73379296 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Mon, 24 Oct 2011 18:54:42 +0700 Subject: [PATCH 2/4] fix bug for tree-to-string. Didn't check sourceLHS --- moses/moses.xcodeproj/project.pbxproj | 4 ++++ moses/src/ChartRuleLookupManagerMemory.cpp | 5 +++++ moses/src/PhraseDictionaryNodeSCFG.cpp | 2 +- moses/src/PhraseDictionarySCFG.cpp | 15 ++++++++++++--- moses/src/PhraseDictionarySCFG.h | 7 ++++--- moses/src/RuleTableLoader.h | 8 +++++--- moses/src/RuleTableLoaderCompact.cpp | 3 ++- moses/src/RuleTableLoaderStandard.cpp | 2 +- 8 files changed, 34 insertions(+), 12 deletions(-) diff --git a/moses/moses.xcodeproj/project.pbxproj b/moses/moses.xcodeproj/project.pbxproj index cd790b14c..8fa2c75a1 100644 --- a/moses/moses.xcodeproj/project.pbxproj +++ b/moses/moses.xcodeproj/project.pbxproj @@ -62,6 +62,7 @@ 1E2E163F132A892800ED4085 /* ThreadPool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E2E1638132A892800ED4085 /* ThreadPool.h */; }; 1E46B5A613BA5C7F0084F898 /* RuleCubeItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E46B5A413BA5C7F0084F898 /* RuleCubeItem.cpp */; }; 1E46B5A713BA5C7F0084F898 /* RuleCubeItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E46B5A513BA5C7F0084F898 /* RuleCubeItem.h */; }; + 1E474E12145575CA00178AD5 /* RuleTableLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E474E11145575CA00178AD5 /* RuleTableLoader.h */; }; 1E528B9D13A12B2D00E9A67E /* params.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E528B9B13A12B2D00E9A67E /* params.cpp */; }; 1E528B9E13A12B2D00E9A67E /* SyntacticLanguageModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E528B9C13A12B2D00E9A67E /* SyntacticLanguageModel.cpp */; }; 1EA6AB4A13BCC838004465AF /* ChartRuleLookupManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1EA6AB4813BCC838004465AF /* ChartRuleLookupManager.cpp */; }; @@ -323,6 +324,7 @@ 1E2E1638132A892800ED4085 /* ThreadPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPool.h; path = src/ThreadPool.h; sourceTree = ""; }; 1E46B5A413BA5C7F0084F898 /* RuleCubeItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RuleCubeItem.cpp; path = src/RuleCubeItem.cpp; sourceTree = ""; }; 1E46B5A513BA5C7F0084F898 /* RuleCubeItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RuleCubeItem.h; path = src/RuleCubeItem.h; sourceTree = ""; }; + 1E474E11145575CA00178AD5 /* RuleTableLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RuleTableLoader.h; path = src/RuleTableLoader.h; sourceTree = ""; }; 1E528B9B13A12B2D00E9A67E /* params.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = params.cpp; path = src/DynSAInclude/params.cpp; sourceTree = ""; }; 1E528B9C13A12B2D00E9A67E /* SyntacticLanguageModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SyntacticLanguageModel.cpp; path = src/SyntacticLanguageModel.cpp; sourceTree = ""; }; 1EA6AB4813BCC838004465AF /* ChartRuleLookupManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChartRuleLookupManager.cpp; path = src/ChartRuleLookupManager.cpp; sourceTree = ""; }; @@ -555,6 +557,7 @@ 08FB7795FE84155DC02AAC07 /* Source */ = { isa = PBXGroup; children = ( + 1E474E11145575CA00178AD5 /* RuleTableLoader.h */, 1E16D086144DAA3F00B60B4F /* LM */, 1ED0FD4C124BB9380029177F /* AlignmentInfo.cpp */, 1ED0FD4D124BB9380029177F /* AlignmentInfo.h */, @@ -996,6 +999,7 @@ 1E16D0B6144DAA6C00B60B4F /* ParallelBackoff.h in Headers */, 1E16D0BC144DAA6C00B60B4F /* SingleFactor.h in Headers */, 1E16D0BE144DAA6C00B60B4F /* SRI.h in Headers */, + 1E474E12145575CA00178AD5 /* RuleTableLoader.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/moses/src/ChartRuleLookupManagerMemory.cpp b/moses/src/ChartRuleLookupManagerMemory.cpp index d49248dbc..953f535a1 100644 --- a/moses/src/ChartRuleLookupManagerMemory.cpp +++ b/moses/src/ChartRuleLookupManagerMemory.cpp @@ -78,6 +78,11 @@ void ChartRuleLookupManagerMemory::GetChartRuleCollection( DottedRuleColl &dottedRuleCol = *m_dottedRuleColls[range.GetStartPos()]; const DottedRuleList &expandableDottedRuleList = dottedRuleCol.GetExpandableDottedRuleList(); + if (range.GetStartPos() == 2 && range.GetEndPos() == 3) + { + std::cerr << "hhh"; + } + const ChartCellLabel &sourceWordLabel = GetCellCollection().Get(WordsRange(absEndPos, absEndPos)).GetSourceWordLabel(); // loop through the rules diff --git a/moses/src/PhraseDictionaryNodeSCFG.cpp b/moses/src/PhraseDictionaryNodeSCFG.cpp index 7f80f8fff..874b906a5 100644 --- a/moses/src/PhraseDictionaryNodeSCFG.cpp +++ b/moses/src/PhraseDictionaryNodeSCFG.cpp @@ -64,7 +64,7 @@ void PhraseDictionaryNodeSCFG::Sort(size_t tableLimit) PhraseDictionaryNodeSCFG *PhraseDictionaryNodeSCFG::GetOrCreateChild(const Word &sourceTerm) { - assert(!sourceTerm.IsNonTerminal()); + //assert(!sourceTerm.IsNonTerminal()); std::pair insResult; insResult = m_sourceTermMap.insert( std::make_pair(sourceTerm, PhraseDictionaryNodeSCFG()) ); diff --git a/moses/src/PhraseDictionarySCFG.cpp b/moses/src/PhraseDictionarySCFG.cpp index e9b4dbf01..d376edb23 100644 --- a/moses/src/PhraseDictionarySCFG.cpp +++ b/moses/src/PhraseDictionarySCFG.cpp @@ -63,13 +63,18 @@ bool PhraseDictionarySCFG::Load(const std::vector &input return ret; } -TargetPhraseCollection &PhraseDictionarySCFG::GetOrCreateTargetPhraseCollection(const Phrase &source, const TargetPhrase &target) +TargetPhraseCollection &PhraseDictionarySCFG::GetOrCreateTargetPhraseCollection( + const Phrase &source + , const TargetPhrase &target + , const Word &sourceLHS) { - PhraseDictionaryNodeSCFG &currNode = GetOrCreateNode(source, target); + PhraseDictionaryNodeSCFG &currNode = GetOrCreateNode(source, target, sourceLHS); return currNode.GetOrCreateTargetPhraseCollection(); } -PhraseDictionaryNodeSCFG &PhraseDictionarySCFG::GetOrCreateNode(const Phrase &source, const TargetPhrase &target) +PhraseDictionaryNodeSCFG &PhraseDictionarySCFG::GetOrCreateNode(const Phrase &source + , const TargetPhrase &target + , const Word &sourceLHS) { const size_t size = source.GetSize(); @@ -97,6 +102,10 @@ PhraseDictionaryNodeSCFG &PhraseDictionarySCFG::GetOrCreateNode(const Phrase &so assert(currNode != NULL); } + + // finally, the source LHS + currNode = currNode->GetOrCreateChild(sourceLHS); + assert(currNode != NULL); return *currNode; } diff --git a/moses/src/PhraseDictionarySCFG.h b/moses/src/PhraseDictionarySCFG.h index 835bce881..4320e264e 100644 --- a/moses/src/PhraseDictionarySCFG.h +++ b/moses/src/PhraseDictionarySCFG.h @@ -78,10 +78,11 @@ class PhraseDictionarySCFG : public PhraseDictionary private: TargetPhraseCollection &GetOrCreateTargetPhraseCollection( - const Phrase &source, const TargetPhrase &target); + const Phrase &source, const TargetPhrase &target, const Word &sourceLHS); - PhraseDictionaryNodeSCFG &GetOrCreateNode(const Phrase &source, - const TargetPhrase &target); + PhraseDictionaryNodeSCFG &GetOrCreateNode(const Phrase &source + , const TargetPhrase &target + , const Word &sourceLHS); void SortAndPrune(); diff --git a/moses/src/RuleTableLoader.h b/moses/src/RuleTableLoader.h index 57fb270e2..b5d4d8e24 100644 --- a/moses/src/RuleTableLoader.h +++ b/moses/src/RuleTableLoader.h @@ -56,9 +56,11 @@ class RuleTableLoader // Provide access to PhraseDictionarySCFG's private // GetOrCreateTargetPhraseCollection function. TargetPhraseCollection &GetOrCreateTargetPhraseCollection( - PhraseDictionarySCFG &ruleTable, const Phrase &source, - const TargetPhrase &target) { - return ruleTable.GetOrCreateTargetPhraseCollection(source, target); + PhraseDictionarySCFG &ruleTable + , const Phrase &source + , const TargetPhrase &target + , const Word &sourceLHS) { + return ruleTable.GetOrCreateTargetPhraseCollection(source, target, sourceLHS); } }; diff --git a/moses/src/RuleTableLoaderCompact.cpp b/moses/src/RuleTableLoaderCompact.cpp index 10e5458aa..39d437b80 100644 --- a/moses/src/RuleTableLoaderCompact.cpp +++ b/moses/src/RuleTableLoaderCompact.cpp @@ -202,6 +202,7 @@ bool RuleTableLoaderCompact::LoadRuleSection( const Phrase &sourcePhrase = sourcePhrases[sourcePhraseId]; const Phrase &targetPhrasePhrase = targetPhrases[targetPhraseId]; const Word &targetLhs = vocab[targetLhsIds[targetPhraseId]]; + Word sourceLHS("X"); // TODO not implemented for compact const AlignmentInfo *alignmentInfo = alignmentSets[alignmentSetId]; // Then there should be one score for each score component. @@ -229,7 +230,7 @@ bool RuleTableLoaderCompact::LoadRuleSection( // Insert rule into table. TargetPhraseCollection &coll = GetOrCreateTargetPhraseCollection( - ruleTable, sourcePhrase, *targetPhrase); + ruleTable, sourcePhrase, *targetPhrase, sourceLHS); coll.Add(targetPhrase); } diff --git a/moses/src/RuleTableLoaderStandard.cpp b/moses/src/RuleTableLoaderStandard.cpp index d8e1314e5..8b17803e7 100644 --- a/moses/src/RuleTableLoaderStandard.cpp +++ b/moses/src/RuleTableLoaderStandard.cpp @@ -118,7 +118,7 @@ bool RuleTableLoaderStandard::Load(const std::vector &input targetPhrase->SetScoreChart(ruleTable.GetFeature(), scoreVector, weight, languageModels,wpProducer); - TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(ruleTable, sourcePhrase, *targetPhrase); + TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(ruleTable, sourcePhrase, *targetPhrase, sourceLHS); phraseColl.Add(targetPhrase); count++; From ae3ecbc1052dbe49e0b80887d63735b991829113 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Mon, 24 Oct 2011 19:13:17 +0700 Subject: [PATCH 3/4] fix bug for tree-to-string. Didn't check source LHS --- moses/src/ChartRuleLookupManagerMemory.cpp | 5 ----- moses/src/PhraseDictionarySCFG.cpp | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/moses/src/ChartRuleLookupManagerMemory.cpp b/moses/src/ChartRuleLookupManagerMemory.cpp index 953f535a1..6b8fc25e5 100644 --- a/moses/src/ChartRuleLookupManagerMemory.cpp +++ b/moses/src/ChartRuleLookupManagerMemory.cpp @@ -77,11 +77,6 @@ void ChartRuleLookupManagerMemory::GetChartRuleCollection( // get list of all rules that apply to spans at same starting position DottedRuleColl &dottedRuleCol = *m_dottedRuleColls[range.GetStartPos()]; const DottedRuleList &expandableDottedRuleList = dottedRuleCol.GetExpandableDottedRuleList(); - - if (range.GetStartPos() == 2 && range.GetEndPos() == 3) - { - std::cerr << "hhh"; - } const ChartCellLabel &sourceWordLabel = GetCellCollection().Get(WordsRange(absEndPos, absEndPos)).GetSourceWordLabel(); diff --git a/moses/src/PhraseDictionarySCFG.cpp b/moses/src/PhraseDictionarySCFG.cpp index d376edb23..4b0f07dce 100644 --- a/moses/src/PhraseDictionarySCFG.cpp +++ b/moses/src/PhraseDictionarySCFG.cpp @@ -104,8 +104,8 @@ PhraseDictionaryNodeSCFG &PhraseDictionarySCFG::GetOrCreateNode(const Phrase &so } // finally, the source LHS - currNode = currNode->GetOrCreateChild(sourceLHS); - assert(currNode != NULL); + //currNode = currNode->GetOrCreateChild(sourceLHS); + //assert(currNode != NULL); return *currNode; } From d98780c062dc605f615833c8e8164adae494e71a Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Mon, 24 Oct 2011 19:13:56 +0700 Subject: [PATCH 4/4] Just get ready but didn't fix bug yet --- moses/src/PhraseDictionarySCFG.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/moses/src/PhraseDictionarySCFG.cpp b/moses/src/PhraseDictionarySCFG.cpp index 4b0f07dce..becd86155 100644 --- a/moses/src/PhraseDictionarySCFG.cpp +++ b/moses/src/PhraseDictionarySCFG.cpp @@ -107,6 +107,7 @@ PhraseDictionaryNodeSCFG &PhraseDictionarySCFG::GetOrCreateNode(const Phrase &so //currNode = currNode->GetOrCreateChild(sourceLHS); //assert(currNode != NULL); + return *currNode; }