variable number of translation component scores

git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@12 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
hieuhoang1972 2006-07-08 02:46:56 +00:00
parent a472843d2e
commit 831d845afa
2 changed files with 15 additions and 4 deletions

View File

@ -5,22 +5,32 @@
#include "PhraseDictionary.h"
TransScoreComponent::TransScoreComponent(const PhraseDictionary *phraseDictionary)
: m_phraseDictionary(phraseDictionary)
{
m_phraseDictionary = phraseDictionary;
m_scoreComponent = (float*) malloc(sizeof(float) * phraseDictionary->GetNoScoreComponent());
}
TransScoreComponent::TransScoreComponent(const TransScoreComponent &copy)
:m_phraseDictionary(copy.m_phraseDictionary)
{
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
size_t noScoreComponent = m_phraseDictionary->GetNoScoreComponent();
m_scoreComponent = (float*) malloc(sizeof(float) * noScoreComponent);
for (size_t i = 0 ; i < noScoreComponent ; i++)
{
m_scoreComponent[i] = copy[i];
}
}
TransScoreComponent::~TransScoreComponent()
{
free(m_scoreComponent);
}
void TransScoreComponent::Reset()
{
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
size_t noScoreComponent = m_phraseDictionary->GetNoScoreComponent();
for (size_t i = 0 ; i < noScoreComponent ; i++)
{
m_scoreComponent[i] = 0;
}

View File

@ -29,7 +29,7 @@ class TransScoreComponent
{
protected:
const PhraseDictionary *m_phraseDictionary;
float m_scoreComponent[NUM_PHRASE_SCORES];
float *m_scoreComponent;
public:
TransScoreComponent()
{ // needed by TransScoreComponentCollection
@ -37,6 +37,7 @@ public:
}
TransScoreComponent(const PhraseDictionary *phraseDictionary);
TransScoreComponent(const TransScoreComponent &copy);
~TransScoreComponent();
void Reset();
size_t GetPhraseDictionaryId() const;