mosesdecoder/contrib/moses2/SCFG/TargetPhraseImpl.h

102 lines
2.2 KiB
C
Raw Normal View History

2016-02-18 22:10:39 +03:00
/*
* TargetPhraseImpl.h
2016-02-18 22:10:39 +03:00
*
* Created on: 23 Oct 2015
* Author: hieu
*/
#pragma once
2016-02-25 19:21:11 +03:00
#include <iostream>
#include "../Phrase.h"
#include "../PhraseImplTemplate.h"
2016-04-26 13:40:57 +03:00
#include "../TargetPhrase.h"
2016-02-25 19:21:11 +03:00
#include "../MemPool.h"
#include "../SubPhrase.h"
2016-04-18 15:16:49 +03:00
#include "../AlignmentInfoCollection.h"
#include "Word.h"
2016-02-18 22:10:39 +03:00
namespace Moses2
{
2016-02-22 22:32:03 +03:00
class Scores;
class Manager;
class System;
class PhraseTable;
2016-04-18 15:16:49 +03:00
class AlignmentInfo;
2016-02-22 22:32:03 +03:00
namespace SCFG
2016-02-18 22:10:39 +03:00
{
2016-04-27 10:53:51 +03:00
class TargetPhraseImpl: public Moses2::TargetPhrase<SCFG::Word>
2016-02-18 22:10:39 +03:00
{
public:
2016-03-03 21:59:10 +03:00
SCFG::Word lhs;
2016-02-22 22:32:03 +03:00
2016-03-31 23:00:16 +03:00
static TargetPhraseImpl *CreateFromString(MemPool &pool,
const PhraseTable &pt, const System &system, const std::string &str);
2016-04-18 15:16:49 +03:00
2016-03-31 23:00:16 +03:00
TargetPhraseImpl(MemPool &pool, const PhraseTable &pt, const System &system,
size_t size);
//TargetPhraseImpl(MemPool &pool, const System &system, const TargetPhraseImpl &copy);
2016-02-18 22:59:22 +03:00
virtual ~TargetPhraseImpl();
2016-02-22 22:32:03 +03:00
2016-04-18 15:16:49 +03:00
// ALNREP = alignment representation,
// see AlignmentInfo constructors for supported representations
template<typename ALNREP>
void
SetAlignTerm(const ALNREP &coll) {
m_alignTerm = AlignmentInfoCollection::Instance().Add(coll);
}
2016-04-18 17:30:45 +03:00
const AlignmentInfo &GetAlignTerm() const {
return *m_alignTerm;
}
const AlignmentInfo &GetAlignNonTerm() const {
return *m_alignNonTerm;
}
2016-08-26 13:25:11 +03:00
void SetAlignTerm(const AlignmentInfo &alignInfo) {
m_alignTerm = &alignInfo;
}
void SetAlignNonTerm(const AlignmentInfo &alignInfo) {
m_alignNonTerm = &alignInfo;
2016-04-18 15:16:49 +03:00
}
void SetAlignmentInfo(const std::string &alignString);
SCORE GetFutureScore() const
{ return m_scores->GetTotalScore() + m_estimatedScore; }
2016-07-15 18:35:38 +03:00
virtual SCORE GetScoreForPruning() const
{ return GetFutureScore(); }
void SetEstimatedScore(const SCORE &value)
{ m_estimatedScore = value; }
2016-07-15 18:35:38 +03:00
2016-06-20 16:59:31 +03:00
std::string Debug(const System &system) const;
2016-06-10 00:55:59 +03:00
size_t GetNumNonTerms() const;
2016-02-25 19:21:11 +03:00
//mutable void *chartState;
2016-02-18 22:10:39 +03:00
protected:
SCORE m_estimatedScore;
2016-08-26 13:25:11 +03:00
const AlignmentInfo* m_alignTerm, *m_alignNonTerm;
// ALNREP = alignment representation,
// see AlignmentInfo constructors for supported representations
template<typename ALNREP>
void
SetAlignNonTerm(const ALNREP &coll) {
m_alignNonTerm = AlignmentInfoCollection::Instance().Add(coll);
}
2016-02-25 19:21:11 +03:00
};
2016-07-15 18:25:48 +03:00
2016-02-18 22:10:39 +03:00
}
}