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
path: root/moses
diff options
context:
space:
mode:
authorHieu Hoang <hieu@hoang.co.uk>2013-05-13 16:19:25 +0400
committerHieu Hoang <hieu@hoang.co.uk>2013-05-13 16:19:25 +0400
commita8cf5c3472d87040a8b199a12f345e752d2d9870 (patch)
tree153db8e48176a488ffa958e51e9b292221754935 /moses
parent3a10197edb6e31409149c60ad804c979d938c609 (diff)
port PhraseDictionaryMultiModel to new format
Diffstat (limited to 'moses')
-rw-r--r--moses/DecodeStepGeneration.cpp2
-rw-r--r--moses/DecodeStepTranslation.cpp2
-rw-r--r--moses/ScoreComponentCollection.cpp8
-rw-r--r--moses/ScoreComponentCollection.h1
-rw-r--r--moses/TargetPhrase.h11
-rw-r--r--moses/TranslationModel/PhraseDictionaryMultiModel.cpp3
6 files changed, 17 insertions, 10 deletions
diff --git a/moses/DecodeStepGeneration.cpp b/moses/DecodeStepGeneration.cpp
index f9827793a..32140557b 100644
--- a/moses/DecodeStepGeneration.cpp
+++ b/moses/DecodeStepGeneration.cpp
@@ -142,7 +142,7 @@ void DecodeStepGeneration::Process(const TranslationOption &inputPartialTranslOp
const TargetPhrase &inPhrase = inputPartialTranslOpt.GetTargetPhrase();
TargetPhrase outPhrase(inPhrase);
- outPhrase.SetScore(generationScore);
+ outPhrase.GetScoreBreakdown().PlusEquals(generationScore);
outPhrase.MergeFactors(genPhrase, m_newOutputFactors);
const WordsRange &sourceWordsRange = inputPartialTranslOpt.GetSourceWordsRange();
diff --git a/moses/DecodeStepTranslation.cpp b/moses/DecodeStepTranslation.cpp
index 9f32b1078..22e0810e1 100644
--- a/moses/DecodeStepTranslation.cpp
+++ b/moses/DecodeStepTranslation.cpp
@@ -76,7 +76,7 @@ void DecodeStepTranslation::Process(const TranslationOption &inputPartialTranslO
continue;
}
- outPhrase.SetScore(transScores);
+ outPhrase.GetScoreBreakdown().PlusEquals(transScores);
outPhrase.Evaluate(); // need to do this as all non-transcores would be screwed up
outPhrase.MergeFactors(targetPhrase, m_newOutputFactors);
diff --git a/moses/ScoreComponentCollection.cpp b/moses/ScoreComponentCollection.cpp
index bd926012d..75241f769 100644
--- a/moses/ScoreComponentCollection.cpp
+++ b/moses/ScoreComponentCollection.cpp
@@ -186,6 +186,14 @@ void ScoreComponentCollection::Assign(const FeatureFunction* sp, const string li
}
}
+void ScoreComponentCollection::ZeroDenseFeatures(const FeatureFunction* sp)
+{
+ size_t numScores = sp->GetNumScoreComponents();
+ Scores vec(numScores, 0);
+
+ Assign(sp, vec);
+}
+
}
diff --git a/moses/ScoreComponentCollection.h b/moses/ScoreComponentCollection.h
index 9d781af54..e93f02eed 100644
--- a/moses/ScoreComponentCollection.h
+++ b/moses/ScoreComponentCollection.h
@@ -388,6 +388,7 @@ public:
float GetWeightedScore() const;
+ void ZeroDenseFeatures(const FeatureFunction* sp);
void ZeroAllLM(const LMList& lmList);
void PlusEqualsAllLM(const LMList& lmList, const ScoreComponentCollection& rhs);
void L1Normalise();
diff --git a/moses/TargetPhrase.h b/moses/TargetPhrase.h
index 0f6dbe192..2e74d90f8 100644
--- a/moses/TargetPhrase.h
+++ b/moses/TargetPhrase.h
@@ -69,11 +69,6 @@ public:
void SetXMLScore(float score);
void SetInputScore(const Scores &scoreVector);
- void SetScore(const ScoreComponentCollection &scores)
- {
- m_scoreBreakdown.PlusEquals(scores);
- }
-
TargetPhrase *MergeNext(const TargetPhrase &targetPhrase) const;
// used for translation step
@@ -92,9 +87,9 @@ public:
}
inline const ScoreComponentCollection &GetScoreBreakdown() const
- {
- return m_scoreBreakdown;
- }
+ { return m_scoreBreakdown; }
+ inline ScoreComponentCollection &GetScoreBreakdown()
+ { return m_scoreBreakdown; }
//TODO: Probably shouldn't copy this, but otherwise ownership is unclear
void SetSourcePhrase(const Phrase& p)
diff --git a/moses/TranslationModel/PhraseDictionaryMultiModel.cpp b/moses/TranslationModel/PhraseDictionaryMultiModel.cpp
index 7b248dc2c..6f4cc3695 100644
--- a/moses/TranslationModel/PhraseDictionaryMultiModel.cpp
+++ b/moses/TranslationModel/PhraseDictionaryMultiModel.cpp
@@ -140,6 +140,9 @@ void PhraseDictionaryMultiModel::CollectSufficientStatistics(const Phrase& src,
multiModelStatistics * statistics = new multiModelStatistics;
statistics->targetPhrase = new TargetPhrase(*targetPhrase); //make a copy so that we don't overwrite the original phrase table info
+ // zero out scores from original phrase table
+ statistics->targetPhrase->GetScoreBreakdown().ZeroDenseFeatures(&pd);
+
Scores scoreVector(m_numScoreComponents);
statistics->p.resize(m_numScoreComponents);
for(size_t j = 0; j < m_numScoreComponents; ++j){