turn references into pointers. For next refactoring

This commit is contained in:
Hieu Hoang 2015-11-05 10:58:41 +00:00
parent c2d3e4f5c9
commit feeb46808b
2 changed files with 16 additions and 16 deletions

View File

@ -20,9 +20,9 @@ Hypothesis::Hypothesis(Manager &mgr,
const Moses::Range &range, const Moses::Range &range,
const Moses::Bitmap &bitmap) const Moses::Bitmap &bitmap)
:m_mgr(mgr) :m_mgr(mgr)
,m_targetPhrase(tp) ,m_targetPhrase(&tp)
,m_sourceCompleted(bitmap) ,m_sourceCompleted(&bitmap)
,m_range(range) ,m_range(&range)
,m_prevHypo(NULL) ,m_prevHypo(NULL)
,m_currTargetWordsRange(NOT_FOUND, NOT_FOUND) ,m_currTargetWordsRange(NOT_FOUND, NOT_FOUND)
{ {
@ -39,9 +39,9 @@ Hypothesis::Hypothesis(const Hypothesis &prevHypo,
const Moses::Range &pathRange, const Moses::Range &pathRange,
const Moses::Bitmap &bitmap) const Moses::Bitmap &bitmap)
:m_mgr(prevHypo.m_mgr) :m_mgr(prevHypo.m_mgr)
,m_targetPhrase(tp) ,m_targetPhrase(&tp)
,m_sourceCompleted(bitmap) ,m_sourceCompleted(&bitmap)
,m_range(pathRange) ,m_range(&pathRange)
,m_prevHypo(&prevHypo) ,m_prevHypo(&prevHypo)
,m_currTargetWordsRange(prevHypo.m_currTargetWordsRange.GetEndPos() + 1, ,m_currTargetWordsRange(prevHypo.m_currTargetWordsRange.GetEndPos() + 1,
prevHypo.m_currTargetWordsRange.GetEndPos() prevHypo.m_currTargetWordsRange.GetEndPos()
@ -56,7 +56,7 @@ Hypothesis::Hypothesis(const Hypothesis &prevHypo,
Scores(pool, Scores(pool,
m_mgr.GetSystem().GetFeatureFunctions().GetNumScores(), m_mgr.GetSystem().GetFeatureFunctions().GetNumScores(),
prevHypo.GetScores()); prevHypo.GetScores());
m_scores->PlusEquals(m_mgr.GetSystem(), m_targetPhrase.GetScores()); m_scores->PlusEquals(m_mgr.GetSystem(), GetTargetPhrase().GetScores());
} }
Hypothesis::~Hypothesis() { Hypothesis::~Hypothesis() {
@ -107,8 +107,8 @@ void Hypothesis::OutputToStream(std::ostream &out) const
m_prevHypo->OutputToStream(out); m_prevHypo->OutputToStream(out);
} }
if (m_targetPhrase.GetSize()) { if (GetTargetPhrase().GetSize()) {
const Phrase &phrase = m_targetPhrase; const Phrase &phrase = GetTargetPhrase();
out << phrase << " "; out << phrase << " ";
} }
} }

View File

@ -37,10 +37,10 @@ public:
bool operator==(const Hypothesis &other) const; bool operator==(const Hypothesis &other) const;
inline const Moses::Bitmap &GetBitmap() const inline const Moses::Bitmap &GetBitmap() const
{ return m_sourceCompleted; } { return *m_sourceCompleted; }
inline const Moses::Range &GetRange() const inline const Moses::Range &GetRange() const
{ return m_range; } { return *m_range; }
inline const Moses::Range &GetCurrTargetWordsRange() const { inline const Moses::Range &GetCurrTargetWordsRange() const {
return m_currTargetWordsRange; return m_currTargetWordsRange;
@ -50,7 +50,7 @@ public:
{ return *m_scores; } { return *m_scores; }
const TargetPhrase &GetTargetPhrase() const const TargetPhrase &GetTargetPhrase() const
{ return m_targetPhrase; } { return *m_targetPhrase; }
const Moses::FFState *GetState(size_t ind) const const Moses::FFState *GetState(size_t ind) const
{ return m_ffStates[ind]; } { return m_ffStates[ind]; }
@ -68,7 +68,7 @@ public:
* (ie, start of sentence would be some negative number, which is * (ie, start of sentence would be some negative number, which is
* not allowed- USE WITH CAUTION) */ * not allowed- USE WITH CAUTION) */
inline const Word &GetCurrWord(size_t pos) const { inline const Word &GetCurrWord(size_t pos) const {
return m_targetPhrase[pos]; return GetTargetPhrase()[pos];
} }
/** recursive - pos is relative from start of sentence */ /** recursive - pos is relative from start of sentence */
@ -76,9 +76,9 @@ public:
protected: protected:
Manager &m_mgr; Manager &m_mgr;
const TargetPhrase &m_targetPhrase; const TargetPhrase *m_targetPhrase;
const Moses::Bitmap &m_sourceCompleted; const Moses::Bitmap *m_sourceCompleted;
const Moses::Range &m_range; const Moses::Range *m_range;
const Hypothesis *m_prevHypo; const Hypothesis *m_prevHypo;
const Moses::FFState **m_ffStates; const Moses::FFState **m_ffStates;