mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-01 08:21:47 +03:00
ScoreComponentCollection to be map !
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@78 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
038ef552b0
commit
257bced4de
@ -3,7 +3,46 @@
|
|||||||
#include "ScoreComponent.h"
|
#include "ScoreComponent.h"
|
||||||
#include "Dictionary.h"
|
#include "Dictionary.h"
|
||||||
|
|
||||||
|
ScoreComponent::ScoreComponent()
|
||||||
|
:m_dictionary(NULL)
|
||||||
|
{ // used by collection
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreComponent::ScoreComponent(const Dictionary *dictionary)
|
||||||
|
:m_dictionary(dictionary)
|
||||||
|
,m_scoreComponent(dictionary->GetNoScoreComponent())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreComponent::ScoreComponent(const ScoreComponent ©)
|
||||||
|
:m_dictionary(copy.m_dictionary)
|
||||||
|
{
|
||||||
|
if (m_dictionary != NULL)
|
||||||
|
{
|
||||||
|
const size_t noScoreComponent = GetNoScoreComponent();
|
||||||
|
for (size_t i = 0 ; i < noScoreComponent ; i++)
|
||||||
|
{
|
||||||
|
m_scoreComponent.push_back(copy[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_t ScoreComponent::GetNoScoreComponent() const
|
size_t ScoreComponent::GetNoScoreComponent() const
|
||||||
{
|
{
|
||||||
return m_dictionary->GetNoScoreComponent();
|
if (m_dictionary != NULL)
|
||||||
}
|
return m_dictionary->GetNoScoreComponent();
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScoreComponent::Reset()
|
||||||
|
{
|
||||||
|
if (m_dictionary != NULL)
|
||||||
|
{
|
||||||
|
const size_t noScoreComponent = GetNoScoreComponent();
|
||||||
|
for (size_t i = 0 ; i < noScoreComponent ; i++)
|
||||||
|
{
|
||||||
|
m_scoreComponent[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "TypeDef.h"
|
#include "TypeDef.h"
|
||||||
|
|
||||||
@ -32,26 +33,13 @@ class Dictionary;
|
|||||||
class ScoreComponent
|
class ScoreComponent
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
const Dictionary *m_dictionary;
|
const Dictionary *m_dictionary;
|
||||||
float m_scoreComponent[NUM_PHRASE_SCORES];
|
std::vector<float> m_scoreComponent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScoreComponent()
|
ScoreComponent();
|
||||||
{ // used by collection
|
ScoreComponent(const Dictionary *dictionary);
|
||||||
}
|
ScoreComponent(const ScoreComponent ©);
|
||||||
|
|
||||||
ScoreComponent(const Dictionary *dictionary)
|
|
||||||
:m_dictionary(dictionary)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
ScoreComponent(const ScoreComponent ©)
|
|
||||||
{
|
|
||||||
m_dictionary = copy.m_dictionary;
|
|
||||||
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
|
|
||||||
{
|
|
||||||
m_scoreComponent[i] = copy[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const Dictionary * GetDictionary() const
|
inline const Dictionary * GetDictionary() const
|
||||||
{
|
{
|
||||||
@ -69,13 +57,7 @@ public:
|
|||||||
return m_scoreComponent[index];
|
return m_scoreComponent[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reset()
|
void Reset();
|
||||||
{
|
|
||||||
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
|
|
||||||
{
|
|
||||||
m_scoreComponent[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Add(const ScoreComponent &source)
|
void Add(const ScoreComponent &source)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user