mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-27 03:49:57 +03:00
use Vector for scores
This commit is contained in:
parent
cd34308236
commit
8d69c1dd38
@ -95,6 +95,26 @@ void Scores::PlusEquals(const System &system,
|
||||
}
|
||||
}
|
||||
|
||||
void Scores::PlusEquals(const System &system,
|
||||
const FeatureFunction &featureFunction,
|
||||
const Vector<SCORE> &scores)
|
||||
{
|
||||
assert(scores.size() == featureFunction.GetNumScores());
|
||||
|
||||
const Weights &weights = system.weights;
|
||||
|
||||
size_t ffStartInd = featureFunction.GetStartInd();
|
||||
for (size_t i = 0; i < scores.size(); ++i) {
|
||||
SCORE incrScore = scores[i];
|
||||
if (m_scores) {
|
||||
m_scores[ffStartInd + i] += incrScore;
|
||||
}
|
||||
//cerr << "ffStartInd=" << ffStartInd << " " << i << endl;
|
||||
SCORE weight = weights[ffStartInd + i];
|
||||
m_total += incrScore * weight;
|
||||
}
|
||||
}
|
||||
|
||||
void Scores::PlusEquals(const System &system, const Scores &other)
|
||||
{
|
||||
size_t numScores = system.featureFunctions.GetNumScores();
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <string>
|
||||
#include "TypeDef.h"
|
||||
#include "MemPool.h"
|
||||
#include "Vector.h"
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
@ -43,6 +44,10 @@ public:
|
||||
const FeatureFunction &featureFunction,
|
||||
const std::vector<SCORE> &scores);
|
||||
|
||||
void PlusEquals(const System &system,
|
||||
const FeatureFunction &featureFunction,
|
||||
const Vector<SCORE> &scores);
|
||||
|
||||
void PlusEquals(const System &system,
|
||||
const Scores &scores);
|
||||
|
||||
|
@ -156,7 +156,7 @@ TargetPhrase *ProbingPT::CreateTargetPhrase(MemPool &pool, const System &system,
|
||||
}
|
||||
|
||||
// score for this phrase table
|
||||
vector<SCORE> scores = probingTargetPhrase.prob;
|
||||
Vector<SCORE> scores(pool, probingTargetPhrase.prob);
|
||||
std::transform(scores.begin(), scores.end(), scores.begin(), TransformScore);
|
||||
tp->GetScores().PlusEquals(system, *this, scores);
|
||||
|
||||
|
@ -35,6 +35,16 @@ public:
|
||||
m_arr = pool.Allocate<T>(size);
|
||||
}
|
||||
|
||||
Vector(MemPool &pool, const std::vector<T> &vec)
|
||||
:m_size(vec.size())
|
||||
,m_maxSize(vec.size())
|
||||
{
|
||||
m_arr = pool.Allocate<T>(m_size);
|
||||
for (size_t i = 0; i < m_size; ++i) {
|
||||
m_arr[i] = vec[i];
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~Vector()
|
||||
{
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user