mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 05:14:36 +03:00
delete Hypothesis::GetSourcePhrase(). Take it directly from TranslationOption::GetSourcePhrase()
This commit is contained in:
parent
6872689bc2
commit
a83c166678
@ -349,7 +349,7 @@ void OutputInput(std::vector<const Phrase*>& map, const Hypothesis* hypo)
|
||||
{
|
||||
if (hypo->GetPrevHypo()) {
|
||||
OutputInput(map, hypo->GetPrevHypo());
|
||||
map[hypo->GetCurrSourceWordsRange().GetStartPos()] = hypo->GetSourcePhrase();
|
||||
map[hypo->GetCurrSourceWordsRange().GetStartPos()] = &hypo->GetTranslationOption().GetSourcePhrase();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "PhraseBoundaryFeature.h"
|
||||
|
||||
#include "moses/Hypothesis.h"
|
||||
#include "moses/TranslationOption.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -77,12 +78,12 @@ FFState* PhraseBoundaryFeature::Evaluate
|
||||
const Word* rightTargetWord = &(targetPhrase.GetWord(0));
|
||||
AddFeatures(leftTargetWord,rightTargetWord,m_targetFactors,"tgt",scores);
|
||||
|
||||
const Phrase* sourcePhrase = cur_hypo.GetSourcePhrase();
|
||||
const Phrase& sourcePhrase = cur_hypo.GetTranslationOption().GetSourcePhrase();
|
||||
const Word* leftSourceWord = pbState->GetSourceWord();
|
||||
const Word* rightSourceWord = &(sourcePhrase->GetWord(0));
|
||||
const Word* rightSourceWord = &(sourcePhrase.GetWord(0));
|
||||
AddFeatures(leftSourceWord,rightSourceWord,m_sourceFactors,"src",scores);
|
||||
|
||||
const Word* endSourceWord = &(sourcePhrase->GetWord(sourcePhrase->GetSize()-1));
|
||||
const Word* endSourceWord = &(sourcePhrase.GetWord(sourcePhrase.GetSize()-1));
|
||||
const Word* endTargetWord = &(targetPhrase.GetWord(targetPhrase.GetSize()-1));
|
||||
|
||||
//if end of sentence add EOS
|
||||
|
@ -48,7 +48,6 @@ ObjectPool<Hypothesis> Hypothesis::s_objectPool("Hypothesis", 300000);
|
||||
Hypothesis::Hypothesis(Manager& manager, InputType const& source, const TargetPhrase &emptyTarget)
|
||||
: m_prevHypo(NULL)
|
||||
, m_targetPhrase(emptyTarget)
|
||||
, m_sourcePhrase(0)
|
||||
, m_sourceCompleted(source.GetSize(), manager.m_source.m_sourceCompleted)
|
||||
, m_sourceInput(source)
|
||||
, m_currSourceWordsRange(
|
||||
@ -80,7 +79,6 @@ Hypothesis::Hypothesis(Manager& manager, InputType const& source, const TargetPh
|
||||
Hypothesis::Hypothesis(const Hypothesis &prevHypo, const TranslationOption &transOpt)
|
||||
: m_prevHypo(&prevHypo)
|
||||
, m_targetPhrase(transOpt.GetTargetPhrase())
|
||||
, m_sourcePhrase(&transOpt.GetSourcePhrase())
|
||||
, m_sourceCompleted (prevHypo.m_sourceCompleted )
|
||||
, m_sourceInput (prevHypo.m_sourceInput)
|
||||
, m_currSourceWordsRange (transOpt.GetSourceWordsRange())
|
||||
@ -348,8 +346,12 @@ void Hypothesis::PrintHypothesis() const
|
||||
}
|
||||
TRACE_ERR( ")"<<endl);
|
||||
TRACE_ERR( "\tbase score "<< (m_prevHypo->m_totalScore - m_prevHypo->m_futureScore) <<endl);
|
||||
TRACE_ERR( "\tcovering "<<m_currSourceWordsRange.GetStartPos()<<"-"<<m_currSourceWordsRange.GetEndPos()<<": "
|
||||
<< *m_sourcePhrase <<endl);
|
||||
TRACE_ERR( "\tcovering "<<m_currSourceWordsRange.GetStartPos()<<"-"<<m_currSourceWordsRange.GetEndPos()<<": ");
|
||||
|
||||
if (m_transOpt) {
|
||||
TRACE_ERR(m_transOpt->GetSourcePhrase());
|
||||
}
|
||||
TRACE_ERR(endl);
|
||||
TRACE_ERR( "\ttranslated as: "<<(Phrase&) m_targetPhrase<<endl); // <<" => translation cost "<<m_score[ScoreType::PhraseTrans];
|
||||
|
||||
if (m_wordDeleted) TRACE_ERR( "\tword deleted"<<endl);
|
||||
@ -440,14 +442,12 @@ std::string Hypothesis::GetSourcePhraseStringRep(const vector<FactorType> factor
|
||||
if (!m_prevHypo) {
|
||||
return "";
|
||||
}
|
||||
return m_sourcePhrase->GetStringRep(factorsToPrint);
|
||||
#if 0
|
||||
if(m_sourcePhrase) {
|
||||
return m_sourcePhrase->GetSubString(m_currSourceWordsRange).GetStringRep(factorsToPrint);
|
||||
} else {
|
||||
return m_sourceInput.GetSubString(m_currSourceWordsRange).GetStringRep(factorsToPrint);
|
||||
if (m_transOpt) {
|
||||
return m_transOpt->GetSourcePhrase().GetStringRep(factorsToPrint);
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
std::string Hypothesis::GetTargetPhraseStringRep(const vector<FactorType> factorsToPrint) const
|
||||
{
|
||||
|
@ -70,7 +70,6 @@ protected:
|
||||
const Hypothesis* m_prevHypo; /*! backpointer to previous hypothesis (from which this one was created) */
|
||||
// const Phrase &m_targetPhrase; /*! target phrase being created at the current decoding step */
|
||||
const TargetPhrase &m_targetPhrase; /*! target phrase being created at the current decoding step */
|
||||
Phrase const* m_sourcePhrase; /*! input sentence */
|
||||
WordsBitmap m_sourceCompleted; /*! keeps track of which words have been translated so far */
|
||||
//TODO: how to integrate this into confusion network framework; what if
|
||||
//it's a confusion network in the end???
|
||||
@ -156,10 +155,6 @@ public:
|
||||
return m_currTargetWordsRange.GetEndPos() + 1;
|
||||
}
|
||||
|
||||
inline const Phrase* GetSourcePhrase() const {
|
||||
return m_sourcePhrase;
|
||||
}
|
||||
|
||||
std::string GetSourcePhraseStringRep(const std::vector<FactorType> factorsToPrint) const;
|
||||
std::string GetTargetPhraseStringRep(const std::vector<FactorType> factorsToPrint) const;
|
||||
std::string GetSourcePhraseStringRep() const;
|
||||
|
@ -21,9 +21,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
***********************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
#include "SentenceStats.h"
|
||||
#include "moses/TranslationOption.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
#include "SentenceStats.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
@ -41,8 +43,9 @@ void SentenceStats::AddDeletedWords(const Hypothesis& hypo)
|
||||
{
|
||||
//don't check either a null pointer or the empty initial hypothesis (if we were given the empty hypo, the null check will save us)
|
||||
if(hypo.GetPrevHypo() != NULL && hypo.GetPrevHypo()->GetCurrSourceWordsRange().GetNumWordsCovered() > 0) AddDeletedWords(*hypo.GetPrevHypo());
|
||||
|
||||
if(hypo.GetCurrTargetWordsRange().GetNumWordsCovered() == 0) {
|
||||
m_deletedWords.push_back(hypo.GetSourcePhrase());
|
||||
m_deletedWords.push_back(&hypo.GetTranslationOption().GetSourcePhrase());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user