diff options
author | Eva <eva@deimos.(none)> | 2012-03-15 04:32:38 +0400 |
---|---|---|
committer | Eva <eva@deimos.(none)> | 2012-03-15 04:32:38 +0400 |
commit | 94fb547b09a191e42e2109c75703afc560a484b8 (patch) | |
tree | 77a05eed99f3491afeea455dba485d1d9c2b158b /moses | |
parent | 797dfad59a55b3996c937f279d4ff280d301627d (diff) | |
parent | b681502605c67fff638899248940979b42704432 (diff) |
Merge branch 'miramerge' of thor.inf.ed.ac.uk:/fs/saxnot3/ehasler/mosesdecoder_github_mira into miramerge
Diffstat (limited to 'moses')
-rw-r--r-- | moses/src/FeatureVector.cpp | 7 | ||||
-rw-r--r-- | moses/src/FeatureVector.h | 3 | ||||
-rw-r--r-- | moses/src/ScoreComponentCollection.cpp | 5 | ||||
-rw-r--r-- | moses/src/ScoreComponentCollection.h | 1 |
4 files changed, 16 insertions, 0 deletions
diff --git a/moses/src/FeatureVector.cpp b/moses/src/FeatureVector.cpp index aef7551f9..7ec5daa3a 100644 --- a/moses/src/FeatureVector.cpp +++ b/moses/src/FeatureVector.cpp @@ -296,6 +296,13 @@ namespace Moses { m_coreFeatures[i] = 1; } + // divide only core features by scalar + FVector& FVector::coreDivideEquals(float scalar) { + for (size_t i = 0; i < m_coreFeatures.size(); ++i) + m_coreFeatures[i] /= scalar; + return *this; + } + // lhs vector is a sum of vectors, rhs vector holds number of non-zero summands FVector& FVector::divideEquals(const FVector& rhs) { assert(m_coreFeatures.size() == rhs.m_coreFeatures.size()); diff --git a/moses/src/FeatureVector.h b/moses/src/FeatureVector.h index c96283a20..8930224d9 100644 --- a/moses/src/FeatureVector.h +++ b/moses/src/FeatureVector.h @@ -195,6 +195,9 @@ namespace Moses { // vector which, for each element of the original vector, reflects whether an element is zero or non-zero void setToBinaryOf(const FVector& rhs); + // divide only core features by scalar + FVector& coreDivideEquals(float scalar); + // divide each element by the number given in the rhs vector FVector& divideEquals(const FVector& rhs); diff --git a/moses/src/ScoreComponentCollection.cpp b/moses/src/ScoreComponentCollection.cpp index cd9957129..39b94b20c 100644 --- a/moses/src/ScoreComponentCollection.cpp +++ b/moses/src/ScoreComponentCollection.cpp @@ -92,6 +92,11 @@ void ScoreComponentCollection::DivideEquals(float scalar) m_scores /= scalar; } +void ScoreComponentCollection::CoreDivideEquals(float scalar) +{ + m_scores.coreDivideEquals(scalar); +} + void ScoreComponentCollection::DivideEquals(const ScoreComponentCollection& rhs) { m_scores.divideEquals(rhs.m_scores); diff --git a/moses/src/ScoreComponentCollection.h b/moses/src/ScoreComponentCollection.h index 9ba3e4948..6728843ac 100644 --- a/moses/src/ScoreComponentCollection.h +++ b/moses/src/ScoreComponentCollection.h @@ -134,6 +134,7 @@ public: void MultiplyEquals(float scalar); void DivideEquals(float scalar); + void CoreDivideEquals(float scalar); void DivideEquals(const ScoreComponentCollection& rhs); void MultiplyEquals(const ScoreComponentCollection& rhs); void MultiplyEquals(const ScoreProducer* sp, float scalar); |