mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 13:23:25 +03:00
variable number of translation component scores
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@11 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
1954227b76
commit
a472843d2e
@ -365,7 +365,7 @@ void Manager::CreatePossibleTranslations(const Phrase &phrase
|
||||
const FactorTypeSet &targetFactors = phraseDictionary.GetFactorsUsed(Target);
|
||||
|
||||
// make sure new phrase isn't deallocated while we're using it
|
||||
m_unknownPhrase.push_back(TargetPhrase(Target, phraseDictionary.GetId()));
|
||||
m_unknownPhrase.push_back(TargetPhrase(Target, &phraseDictionary));
|
||||
TargetPhrase &targetPhrase = m_unknownPhrase.back();
|
||||
FactorArray &targetWord = targetPhrase.AddWord();
|
||||
|
||||
|
@ -94,7 +94,7 @@ void PhraseDictionary::Load(const std::vector<FactorType> &input
|
||||
Phrase sourcePhrase(Source);
|
||||
sourcePhrase.CreateFromString( input, phraseVector, factorCollection);
|
||||
//target
|
||||
TargetPhrase targetPhrase(Target, m_id);
|
||||
TargetPhrase targetPhrase(Target, this);
|
||||
targetPhrase.CreateFromString( output, token[1], factorCollection);
|
||||
|
||||
// component score, for n-best output
|
||||
|
@ -53,8 +53,8 @@ protected:
|
||||
public:
|
||||
PhraseDictionary(size_t id, size_t noScoreComponent)
|
||||
:m_id(id)
|
||||
,m_factorsUsed(2)
|
||||
,m_noScoreComponent(noScoreComponent)
|
||||
,m_factorsUsed(2)
|
||||
{
|
||||
}
|
||||
~PhraseDictionary();
|
||||
|
@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "Phrase.h"
|
||||
#include "TransScoreComponent.h"
|
||||
|
||||
class PhraseDictionary;
|
||||
|
||||
class TargetPhrase: public Phrase
|
||||
{
|
||||
protected:
|
||||
@ -34,10 +36,10 @@ protected:
|
||||
#endif
|
||||
|
||||
public:
|
||||
TargetPhrase(Language language, size_t idPhraseDictionary)
|
||||
TargetPhrase(Language language, const PhraseDictionary *phraseDictionary)
|
||||
:Phrase(language)
|
||||
#ifdef N_BEST
|
||||
,m_scoreComponent(idPhraseDictionary)
|
||||
,m_scoreComponent(phraseDictionary)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
33
moses/src/TransScoreComponent.cpp
Normal file
33
moses/src/TransScoreComponent.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
#include "TypeDef.h"
|
||||
#include "Util.h"
|
||||
#include "TransScoreComponent.h"
|
||||
#include "PhraseDictionary.h"
|
||||
|
||||
TransScoreComponent::TransScoreComponent(const PhraseDictionary *phraseDictionary)
|
||||
{
|
||||
m_phraseDictionary = phraseDictionary;
|
||||
}
|
||||
|
||||
TransScoreComponent::TransScoreComponent(const TransScoreComponent ©)
|
||||
:m_phraseDictionary(copy.m_phraseDictionary)
|
||||
{
|
||||
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
|
||||
{
|
||||
m_scoreComponent[i] = copy[i];
|
||||
}
|
||||
}
|
||||
|
||||
void TransScoreComponent::Reset()
|
||||
{
|
||||
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
|
||||
{
|
||||
m_scoreComponent[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
size_t TransScoreComponent::GetPhraseDictionaryId() const
|
||||
{
|
||||
return m_phraseDictionary->GetId();
|
||||
}
|
||||
|
@ -23,34 +23,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include <iostream>
|
||||
|
||||
//typedef float TransScoreComponent[NUM_PHRASE_SCORES];
|
||||
class PhraseDictionary;
|
||||
|
||||
class TransScoreComponent
|
||||
{
|
||||
protected:
|
||||
size_t m_idPhraseDictionary;
|
||||
const PhraseDictionary *m_phraseDictionary;
|
||||
float m_scoreComponent[NUM_PHRASE_SCORES];
|
||||
public:
|
||||
TransScoreComponent()
|
||||
{
|
||||
}
|
||||
TransScoreComponent(size_t idPhraseDictionary)
|
||||
{
|
||||
m_idPhraseDictionary = idPhraseDictionary;
|
||||
}
|
||||
TransScoreComponent(const TransScoreComponent ©)
|
||||
{
|
||||
m_idPhraseDictionary = copy.m_idPhraseDictionary;
|
||||
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
|
||||
{
|
||||
m_scoreComponent[i] = copy[i];
|
||||
}
|
||||
{ // needed by TransScoreComponentCollection
|
||||
// should try & get rid of it
|
||||
}
|
||||
TransScoreComponent(const PhraseDictionary *phraseDictionary);
|
||||
TransScoreComponent(const TransScoreComponent ©);
|
||||
void Reset();
|
||||
|
||||
inline size_t GetPhraseDictionaryId() const
|
||||
{
|
||||
return m_idPhraseDictionary;
|
||||
}
|
||||
size_t GetPhraseDictionaryId() const;
|
||||
|
||||
float operator[](size_t index) const
|
||||
{
|
||||
@ -61,13 +50,6 @@ public:
|
||||
return m_scoreComponent[index];
|
||||
}
|
||||
|
||||
void Reset()
|
||||
{
|
||||
for (size_t i = 0 ; i < NUM_PHRASE_SCORES ; i++)
|
||||
{
|
||||
m_scoreComponent[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool operator< (const TransScoreComponent &compare) const
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
}
|
||||
TransScoreComponent &Add(const PhraseDictionary &phraseDictionary)
|
||||
{
|
||||
return Add(TransScoreComponent(phraseDictionary.GetId()));
|
||||
return Add(TransScoreComponent(&phraseDictionary));
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user