get ready to delete source phrase from TargetPhrase class

This commit is contained in:
Hieu Hoang 2013-08-07 11:37:40 +01:00
parent 66d4c2b0be
commit a1f5167f85
13 changed files with 17 additions and 31 deletions

View File

@ -275,7 +275,6 @@ Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::Facto
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);

View File

@ -450,7 +450,7 @@ void OutputNBest(std::ostream& out
}
if (StaticData::Instance().IsPathRecoveryEnabled()) {
out << "|||";
out << " ||| ";
OutputInput(out, edges[0]);
}

View File

@ -94,7 +94,6 @@ void ChartParserUnknown::Process(const Word &sourceWord, const WordsRange &range
targetPhrase->GetScoreBreakdown().Assign(unknownWordPenaltyProducer, unknownScore);
targetPhrase->Evaluate(*unksrc);
targetPhrase->SetSourcePhrase(*unksrc);
targetPhrase->SetTargetLHS(targetLHS);
targetPhrase->SetAlignmentInfo("0-0");
@ -120,7 +119,6 @@ void ChartParserUnknown::Process(const Word &sourceWord, const WordsRange &range
targetPhrase->GetScoreBreakdown().Assign(unknownWordPenaltyProducer, unknownScore);
targetPhrase->Evaluate(*unksrc);
targetPhrase->SetSourcePhrase(*unksrc);
targetPhrase->SetTargetLHS(targetLHS);
// chart rule

View File

@ -232,7 +232,7 @@ void DecodeStepTranslation::ProcessInitialTranslationLegacy(
const InputPath &DecodeStepTranslation::GetInputPathLegacy(const TargetPhrase targetPhrase,
const InputPathList &inputPathList) const
{
const Phrase &phraseFromTP = targetPhrase.GetSourcePhrase();
const Phrase &phraseFromTP = targetPhrase.GetSourcePhraseAA();
const Word &wordTP = phraseFromTP.GetWord(0);
InputPathList::const_iterator iter;

View File

@ -141,12 +141,13 @@ void WordTranslationFeature::Evaluate
ScoreComponentCollection* accumulator) const
{
const Sentence& input = static_cast<const Sentence&>(context.GetSource());
const TranslationOption& transOpt = context.GetTranslationOption();
const TargetPhrase& targetPhrase = context.GetTargetPhrase();
const AlignmentInfo &alignment = targetPhrase.GetAlignTerm();
// process aligned words
for (AlignmentInfo::const_iterator alignmentPoint = alignment.begin(); alignmentPoint != alignment.end(); alignmentPoint++) {
const Phrase& sourcePhrase = targetPhrase.GetSourcePhrase();
const Phrase& sourcePhrase = transOpt.GetSourcePhrase();
int sourceIndex = alignmentPoint->first;
int targetIndex = alignmentPoint->second;
Word ws = sourcePhrase.GetWord(sourceIndex);
@ -356,7 +357,7 @@ void WordTranslationFeature::EvaluateChart(
// process aligned words
for (AlignmentInfo::const_iterator alignmentPoint = alignmentInfo.begin(); alignmentPoint != alignmentInfo.end(); alignmentPoint++) {
const Phrase& sourcePhrase = targetPhrase.GetSourcePhrase();
const Phrase& sourcePhrase = targetPhrase.GetSourcePhraseAA();
int sourceIndex = alignmentPoint->first;
int targetIndex = alignmentPoint->second;
Word ws = sourcePhrase.GetWord(sourceIndex);

View File

@ -294,7 +294,7 @@ public:
}
}
targetPhrase.SetSourcePhrase(*srcPtr);
targetPhrase.SetSourcePhraseAA(*srcPtr);
if (alignmentString) {
targetPhrase.SetAlignmentInfo(*alignmentString);

View File

@ -41,7 +41,7 @@ TargetPhrase::TargetPhrase( std::string out_string)
:Phrase(0)
, m_fullScore(0.0)
, m_futureScore(0.0)
, m_sourcePhrase(0)
, m_sourcePhraseAA(0)
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
@ -56,7 +56,7 @@ TargetPhrase::TargetPhrase()
:Phrase()
, m_fullScore(0.0)
, m_futureScore(0.0)
,m_sourcePhrase()
,m_sourcePhraseAA()
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
@ -67,7 +67,7 @@ TargetPhrase::TargetPhrase(const Phrase &phrase)
: Phrase(phrase)
, m_fullScore(0.0)
, m_futureScore(0.0)
, m_sourcePhrase()
, m_sourcePhraseAA()
, m_alignTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_alignNonTerm(&AlignmentInfoCollection::Instance().GetEmptyAlignmentInfo())
, m_lhsTarget(NULL)
@ -79,7 +79,7 @@ TargetPhrase::TargetPhrase(const TargetPhrase &copy)
, m_fullScore(copy.m_fullScore)
, m_futureScore(copy.m_futureScore)
, m_scoreBreakdown(copy.m_scoreBreakdown)
, m_sourcePhrase(copy.m_sourcePhrase)
, m_sourcePhraseAA(copy.m_sourcePhraseAA)
, m_alignTerm(copy.m_alignTerm)
, m_alignNonTerm(copy.m_alignNonTerm)
{

View File

@ -49,7 +49,7 @@ protected:
ScoreComponentCollection m_scoreBreakdown;
// in case of confusion net, ptr to source phrase
Phrase m_sourcePhrase;
Phrase m_sourcePhraseAA;
const AlignmentInfo* m_alignTerm, *m_alignNonTerm;
const Word *m_lhsTarget;
@ -93,11 +93,11 @@ public:
}
//TODO: Probably shouldn't copy this, but otherwise ownership is unclear
void SetSourcePhrase(const Phrase& p) {
m_sourcePhrase=p;
void SetSourcePhraseAA(const Phrase& p) {
m_sourcePhraseAA=p;
}
const Phrase& GetSourcePhrase() const {
return m_sourcePhrase;
const Phrase& GetSourcePhraseAA() const {
return m_sourcePhraseAA;
}
void SetTargetLHS(const Word *lhs) {
@ -139,7 +139,7 @@ struct TargetPhraseHasher {
inline size_t operator()(const TargetPhrase& targetPhrase) const {
size_t seed = 0;
boost::hash_combine(seed, targetPhrase);
boost::hash_combine(seed, targetPhrase.GetSourcePhrase());
boost::hash_combine(seed, targetPhrase.GetSourcePhraseAA());
boost::hash_combine(seed, targetPhrase.GetAlignTerm());
boost::hash_combine(seed, targetPhrase.GetAlignNonTerm());
@ -150,7 +150,7 @@ struct TargetPhraseHasher {
struct TargetPhraseComparator {
inline bool operator()(const TargetPhrase& lhs, const TargetPhrase& rhs) const {
return lhs.Compare(rhs) == 0 &&
lhs.GetSourcePhrase().Compare(rhs.GetSourcePhrase()) == 0 &&
lhs.GetSourcePhraseAA().Compare(rhs.GetSourcePhraseAA()) == 0 &&
lhs.GetAlignTerm() == rhs.GetAlignTerm() &&
lhs.GetAlignNonTerm() == rhs.GetAlignNonTerm();
}

View File

@ -478,7 +478,6 @@ GetMosesFactorIDs(const SAPhrase& phrase, const Phrase& sourcePhrase) const
CHECK(word != m_trgVocab->GetkOOVWord());
targetPhrase->AddWord(word);
}
targetPhrase->SetSourcePhrase(sourcePhrase);
// scoring
return targetPhrase;
}

View File

@ -279,7 +279,6 @@ TargetPhraseVectorPtr PhraseDecoder::DecodeCollection(
tpv->push_back(TargetPhrase());
targetPhrase = &tpv->back();
targetPhrase->SetSourcePhrase(sourcePhrase);
alignment.clear();
scores.clear();

View File

@ -225,7 +225,6 @@ bool RuleTableLoaderCompact::LoadRuleSection(
TargetPhrase *targetPhrase = new TargetPhrase(targetPhrasePhrase);
targetPhrase->SetAlignNonTerm(alignNonTerm);
targetPhrase->SetTargetLHS(targetLhs);
targetPhrase->SetSourcePhrase(sourcePhrase);
targetPhrase->Evaluate(sourcePhrase, ruleTable.GetFeaturesToApply());

View File

@ -228,7 +228,6 @@ bool RuleTableLoaderStandard::Load(FormatType format
// source
Phrase sourcePhrase;
sourcePhrase.CreateFromString(Input, input, sourcePhraseString, factorDelimiter, &sourceLHS);
targetPhrase->SetSourcePhrase(sourcePhrase);
// rest of target phrase
targetPhrase->SetAlignmentInfo(alignString);

View File

@ -205,14 +205,6 @@ void TranslationOptionCollectionConfusionNet::CreateTranslationOptionsForRangeLe
(m_source, *oldPtoc
, startPos, endPos, adhereTableLimit, inputPathList );
PartialTranslOptColl::const_iterator iter;
for (iter = oldPtoc->begin(); iter != oldPtoc->end(); ++iter) {
TranslationOption &transOpt = **iter;
const TargetPhrase &tp = transOpt.GetTargetPhrase();
const Phrase &sp = tp.GetSourcePhrase();
cerr << "sp=" << sp << endl;
}
// do rest of decode steps
int indexStep = 0;