mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
TranslationOption::GetSourcePhrase() return a reference, not a pointer. It must always have the reference
This commit is contained in:
parent
dbc545089b
commit
6872689bc2
@ -110,7 +110,7 @@ void PhrasePairFeature::Evaluate(
|
||||
ScoreComponentCollection* accumulator) const
|
||||
{
|
||||
const TargetPhrase& target = context.GetTargetPhrase();
|
||||
const Phrase& source = *(context.GetTranslationOption().GetSourcePhrase());
|
||||
const Phrase& source = context.GetTranslationOption().GetSourcePhrase();
|
||||
if (m_simple) {
|
||||
ostringstream namestr;
|
||||
namestr << "pp_";
|
||||
|
@ -80,7 +80,7 @@ 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_sourcePhrase(&transOpt.GetSourcePhrase())
|
||||
, m_sourceCompleted (prevHypo.m_sourceCompleted )
|
||||
, m_sourceInput (prevHypo.m_sourceInput)
|
||||
, m_currSourceWordsRange (transOpt.GetSourceWordsRange())
|
||||
|
@ -95,8 +95,8 @@ public:
|
||||
}
|
||||
|
||||
/** returns source phrase */
|
||||
const Phrase *GetSourcePhrase() const {
|
||||
return &(m_targetPhrase.GetSourcePhrase());
|
||||
const Phrase &GetSourcePhrase() const {
|
||||
return m_targetPhrase.GetSourcePhrase();
|
||||
}
|
||||
|
||||
/** whether source span overlaps with those of a hypothesis */
|
||||
|
@ -655,13 +655,11 @@ void TranslationOptionCollection::CacheLexReordering()
|
||||
for(iterTransOpt = transOptList.begin() ; iterTransOpt != transOptList.end() ; ++iterTransOpt) {
|
||||
TranslationOption &transOpt = **iterTransOpt;
|
||||
//Phrase sourcePhrase = m_source.GetSubString(WordsRange(startPos,endPos));
|
||||
const Phrase *sourcePhrase = transOpt.GetSourcePhrase();
|
||||
if (sourcePhrase) {
|
||||
Scores score = lexreordering.GetProb(*sourcePhrase
|
||||
, transOpt.GetTargetPhrase());
|
||||
if (!score.empty())
|
||||
transOpt.CacheLexReorderingScores(lexreordering, score);
|
||||
} // if (sourcePhrase) {
|
||||
const Phrase &sourcePhrase = transOpt.GetSourcePhrase();
|
||||
Scores score = lexreordering.GetProb(sourcePhrase
|
||||
, transOpt.GetTargetPhrase());
|
||||
if (!score.empty())
|
||||
transOpt.CacheLexReorderingScores(lexreordering, score);
|
||||
} // for(iterTransOpt
|
||||
} // for (size_t endPos = startPos ; endPos < startPos + maxSize; endPos++) {
|
||||
} // for (size_t startPos = 0 ; startPos < size ; startPos++) {
|
||||
|
Loading…
Reference in New Issue
Block a user