Get ready to make lhsTarget a pointer

This commit is contained in:
Hieu Hoang 2013-05-22 10:57:19 +01:00
parent 4fdda2e2d9
commit 53d625de5b
2 changed files with 32 additions and 18 deletions

View File

@ -39,9 +39,10 @@ using namespace std;
namespace Moses
{
TargetPhrase::TargetPhrase( std::string out_string)
:Phrase(0), m_fullScore(0.0), m_sourcePhrase(0)
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
:Phrase(0), m_fullScore(0.0), m_sourcePhrase(0)
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
{
//ACAT
@ -50,11 +51,22 @@ TargetPhrase::TargetPhrase( std::string out_string)
}
TargetPhrase::TargetPhrase()
:Phrase()
, m_fullScore(0.0)
,m_sourcePhrase()
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
:Phrase()
, m_fullScore(0.0)
,m_sourcePhrase()
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
{
}
TargetPhrase::TargetPhrase(const Phrase &phrase)
: Phrase(phrase)
, m_fullScore(0.0)
, m_sourcePhrase()
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
{
}
@ -66,19 +78,20 @@ TargetPhrase::TargetPhrase(const TargetPhrase &copy)
, m_alignNonTerm(copy.m_alignNonTerm)
, m_scoreBreakdown(copy.m_scoreBreakdown)
{
if (copy.m_lhsTarget) {
m_lhsTarget = new Word(copy.m_lhsTarget);
}
else {
m_lhsTarget = NULL;
}
}
TargetPhrase::TargetPhrase(const Phrase &phrase)
: Phrase(phrase)
, m_fullScore(0.0)
, m_sourcePhrase()
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
TargetPhrase::~TargetPhrase()
{
delete m_lhsTarget;
}
#ifdef HAVE_PROTOBUF
void TargetPhrase::WriteToRulePB(hgmert::Rule* pb) const
{

View File

@ -51,13 +51,14 @@ protected:
// in case of confusion net, ptr to source phrase
Phrase m_sourcePhrase;
const AlignmentInfo* m_alignTerm, *m_alignNonTerm;
Word m_lhsTarget;
Word *m_lhsTarget;
public:
TargetPhrase();
TargetPhrase(const TargetPhrase &copy);
explicit TargetPhrase(std::string out_string);
explicit TargetPhrase(const Phrase &targetPhrase);
~TargetPhrase();
void Evaluate();
@ -104,9 +105,9 @@ public:
}
void SetTargetLHS(const Word &lhs)
{ m_lhsTarget = lhs; }
{ m_lhsTarget = new Word(lhs); }
const Word &GetTargetLHS() const
{ return m_lhsTarget; }
{ return *m_lhsTarget; }
void SetAlignmentInfo(const StringPiece &alignString);
void SetAlignTerm(const AlignmentInfo *alignTerm) {