mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-26 11:28:48 +03:00
delete sourcePhrase variable in TargetPhrase class
This commit is contained in:
parent
ae82d02a05
commit
805eef6c18
@ -240,10 +240,6 @@ Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::Facto
|
||||
GetWord(pos).ConvertToMoses(outputFactors, vocab, ret->AddWord());
|
||||
}
|
||||
|
||||
// scores
|
||||
ret->GetScoreBreakdown().Assign(&phraseDict, m_scores);
|
||||
ret->Evaluate();
|
||||
|
||||
// alignments
|
||||
int index = 0;
|
||||
Moses::AlignmentInfo::CollType alignTerm, alignNonTerm;
|
||||
@ -269,14 +265,18 @@ Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::Facto
|
||||
Moses::Word *lhsTarget = new Moses::Word(true);
|
||||
GetWord(GetSize() - 1).ConvertToMoses(outputFactors, vocab, *lhsTarget);
|
||||
ret->SetTargetLHS(lhsTarget);
|
||||
|
||||
|
||||
// set source phrase
|
||||
Moses::Phrase mosesSP(Moses::Input);
|
||||
for (size_t pos = 0; pos < sp->GetSize(); ++pos) {
|
||||
sp->GetWord(pos).ConvertToMoses(inputFactors, vocab, mosesSP.AddWord());
|
||||
}
|
||||
ret->SetSourcePhrase(mosesSP);
|
||||
|
||||
|
||||
// scores
|
||||
ret->GetScoreBreakdown().Assign(&phraseDict, m_scores);
|
||||
ret->Evaluate(mosesSP);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "util/check.hh"
|
||||
#include "TypeDef.h"
|
||||
#include "FactorTypeSet.h"
|
||||
#include "Phrase.h"
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
@ -99,7 +100,8 @@ public:
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit) const = 0;
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -63,7 +63,8 @@ void DecodeStepGeneration::Process(const TranslationOption &inputPartialTranslOp
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection * /* toc */
|
||||
, bool /*adhereTableLimit*/) const
|
||||
, bool /*adhereTableLimit*/
|
||||
, const Phrase &src) const
|
||||
{
|
||||
if (inputPartialTranslOpt.GetTargetPhrase().GetSize() == 0) {
|
||||
// word deletion
|
||||
|
@ -42,7 +42,8 @@ public:
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit) const;
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const;
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -38,13 +38,12 @@ void DecodeStepTranslation::Process(const TranslationOption &inputPartialTranslO
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit) const
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const
|
||||
{
|
||||
if (inputPartialTranslOpt.GetTargetPhrase().GetSize() == 0) {
|
||||
// word deletion
|
||||
|
||||
outputPartialTranslOptColl.Add(new TranslationOption(inputPartialTranslOpt));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,7 +76,7 @@ void DecodeStepTranslation::Process(const TranslationOption &inputPartialTranslO
|
||||
}
|
||||
|
||||
outPhrase.GetScoreBreakdown().PlusEquals(transScores);
|
||||
outPhrase.Evaluate(); // need to do this as all non-transcores would be screwed up
|
||||
outPhrase.Evaluate(src); // need to do this as all non-transcores would be screwed up
|
||||
|
||||
outPhrase.MergeFactors(targetPhrase, m_newOutputFactors);
|
||||
|
||||
|
@ -43,7 +43,8 @@ public:
|
||||
, const DecodeStep &decodeStep
|
||||
, PartialTranslOptColl &outputPartialTranslOptColl
|
||||
, TranslationOptionCollection *toc
|
||||
, bool adhereTableLimit) const;
|
||||
, bool adhereTableLimit
|
||||
, const Phrase &src) const;
|
||||
|
||||
|
||||
/*! initialize list of partial translation options by applying the first translation step
|
||||
|
@ -126,7 +126,7 @@ void TargetPhrase::Evaluate(const InputType &input)
|
||||
|
||||
for (size_t i = 0; i < ffs.size(); ++i) {
|
||||
const FeatureFunction &ff = *ffs[i];
|
||||
ff.Evaluate(source, m_scoreBreakdown);
|
||||
ff.Evaluate(input, m_scoreBreakdown);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ void TranslationOptionCollection::ProcessOneUnknownWord(const Word &sourceWord,s
|
||||
targetPhrase.SetInputScore(*inputScores);
|
||||
}
|
||||
|
||||
targetPhrase.Evaluate();
|
||||
targetPhrase.Evaluate(*m_unksrc);
|
||||
|
||||
transOpt = new TranslationOption(WordsRange(sourcePos, sourcePos + length - 1), targetPhrase);
|
||||
Add(transOpt);
|
||||
@ -527,7 +527,8 @@ void TranslationOptionCollection::CreateTranslationOptionsForRange(
|
||||
, decodeStep
|
||||
, *newPtoc
|
||||
, this
|
||||
, adhereTableLimit);
|
||||
, adhereTableLimit
|
||||
, *sourcePhrase);
|
||||
}
|
||||
|
||||
// last but 1 partial trans not required anymore
|
||||
|
@ -186,6 +186,9 @@ bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector<XMLParseOutput>
|
||||
CHECK(targetLHS->GetFactor(0) != NULL);
|
||||
targetPhrase.SetTargetLHS(targetLHS);
|
||||
|
||||
// not tested
|
||||
Phrase sourcePhrase = this->GetSubString(WordsRange(startPos,endPos-1));
|
||||
|
||||
// get probability
|
||||
float probValue = 1;
|
||||
if (altProbs.size() > i && altProbs[i].size() > 0) {
|
||||
@ -194,7 +197,7 @@ bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector<XMLParseOutput>
|
||||
// convert from prob to log-prob
|
||||
float scoreValue = FloorScore(TransformScore(probValue));
|
||||
targetPhrase.SetXMLScore(scoreValue);
|
||||
targetPhrase.Evaluate();
|
||||
targetPhrase.Evaluate(sourcePhrase);
|
||||
|
||||
// set span and create XmlOption
|
||||
WordsRange range(startPos+1,endPos);
|
||||
|
@ -332,6 +332,8 @@ bool ProcessAndStripXMLTags(string &line, vector<XmlOption*> &res, ReorderingCon
|
||||
if (StaticData::Instance().GetXmlInputType() != XmlIgnore) {
|
||||
// only store options if we aren't ignoring them
|
||||
for (size_t i=0; i<altTexts.size(); ++i) {
|
||||
Phrase sourcePhrase; // TODO don't know what the source phrase is
|
||||
|
||||
// set default probability
|
||||
float probValue = 1;
|
||||
if (altProbs.size() > 0) probValue = Scan<float>(altProbs[i]);
|
||||
@ -343,7 +345,7 @@ bool ProcessAndStripXMLTags(string &line, vector<XmlOption*> &res, ReorderingCon
|
||||
targetPhrase.CreateFromString(Output, outputFactorOrder,altTexts[i],factorDelimiter, NULL);
|
||||
|
||||
targetPhrase.SetXMLScore(scoreValue);
|
||||
targetPhrase.Evaluate();
|
||||
targetPhrase.Evaluate(sourcePhrase);
|
||||
|
||||
XmlOption *option = new XmlOption(range,targetPhrase);
|
||||
CHECK(option);
|
||||
|
Loading…
Reference in New Issue
Block a user