mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-29 06:52:34 +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 "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
|
||||
{
|
||||
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
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include "TypeDef.h"
|
||||
|
||||
@ -32,26 +33,13 @@ class Dictionary;
|
||||
class ScoreComponent
|
||||
{
|
||||
protected:
|
||||
const Dictionary *m_dictionary;
|
||||
float m_scoreComponent[NUM_PHRASE_SCORES];
|
||||
const Dictionary *m_dictionary;
|
||||
std::vector<float> m_scoreComponent;
|
||||
|
||||
public:
|
||||
ScoreComponent()
|
||||
{ // used by collection
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
ScoreComponent();
|
||||
ScoreComponent(const Dictionary *dictionary);
|
||||
ScoreComponent(const ScoreComponent ©);
|
||||
|
||||
inline const Dictionary * GetDictionary() const
|
||||
{
|
||||
@ -69,13 +57,7 @@ public:
|
||||
return m_scoreComponent[index];
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
|
||||
{
|
||||
m_scoreComponent[i] = 0;
|
||||
}
|
||||
}
|
||||
void Reset();
|
||||
|
||||
void Add(const ScoreComponent &source)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user