diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2012-10-19 18:10:10 +0400 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2012-10-19 18:10:10 +0400 |
commit | 397e704b49eda68443c88c30ff4b62f07cfb0b45 (patch) | |
tree | 536406b620ee4cdc4935b0051ae30a5dd3b3a40c /OnDiskPt | |
parent | fb040861f7496a878456302447ba1fecd4754b1a (diff) |
terminal and non-terminal word alignments stored in 2 separate objects
Diffstat (limited to 'OnDiskPt')
-rw-r--r-- | OnDiskPt/TargetPhrase.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/OnDiskPt/TargetPhrase.cpp b/OnDiskPt/TargetPhrase.cpp index e7123af3b..ecb5d384d 100644 --- a/OnDiskPt/TargetPhrase.cpp +++ b/OnDiskPt/TargetPhrase.cpp @@ -247,17 +247,26 @@ Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::Facto ret->SetScoreChart(phraseDict.GetFeature(), m_scores, weightT, lmList, wpProducer); // alignments - int indicator[m_align.size()]; int index = 0; + Moses::AlignmentInfo::CollType alignTerm, alignNonTerm; std::set<std::pair<size_t, size_t> > alignmentInfo; const PhrasePtr sp = GetSourcePhrase(); for (size_t ind = 0; ind < m_align.size(); ++ind) { const std::pair<size_t, size_t> &entry = m_align[ind]; alignmentInfo.insert(entry); size_t sourcePos = entry.first; - indicator[index++] = sp->GetWord(sourcePos).IsNonTerminal() ? 1: 0; + size_t targetPos = entry.second; + + if (GetWord(targetPos).IsNonTerminal()) { + alignNonTerm.insert(std::pair<size_t,size_t>(sourcePos, targetPos)); + } + else { + alignTerm.insert(std::pair<size_t,size_t>(sourcePos, targetPos)); + } + } - ret->SetAlignmentInfo(alignmentInfo, indicator); + ret->SetAlignTerm(alignTerm); + ret->SetAlignNonTerm(alignNonTerm); GetWord(GetSize() - 1).ConvertToMoses(outputFactors, vocab, ret->MutableTargetLHS()); |