Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::FactorType> & /*inputFactors */
    , const std::vector<Moses::FactorType> &outputFactors
    , const Vocab &vocab
    , const Moses::PhraseDictionary &phraseDict
    , const std::vector<float> &weightT
    , const Moses::WordPenaltyProducer* wpProducer
    , const Moses::LMList &lmList) const
{
  Moses::TargetPhrase *ret = new Moses::TargetPhrase(Moses::Output);

  // words
  size_t phraseSize = GetSize();
  CHECK(phraseSize > 0); // last word is lhs
  --phraseSize;

  for (size_t pos = 0; pos < phraseSize; ++pos) {
    GetWord(pos).ConvertToMoses(outputFactors, vocab, ret->AddWord());
  }

  // scores
  ret->SetScoreChart(phraseDict.GetFeature(), m_scores, weightT, lmList, wpProducer);

  // alignments
  std::set<std::pair<size_t, size_t> > alignmentInfo;
  for (size_t ind = 0; ind < m_align.size(); ++ind) {
    const std::pair<size_t, size_t> &entry = m_align[ind];
    alignmentInfo.insert(entry);
  }
  ret->SetAlignmentInfo(alignmentInfo);

  GetWord(GetSize() - 1).ConvertToMoses(outputFactors, vocab, ret->MutableTargetLHS());

  return ret;
}
Exemple #2
0
Moses::TargetPhrase *TargetPhrase::ConvertToMoses(const std::vector<Moses::FactorType> &inputFactors
																		, const std::vector<Moses::FactorType> &outputFactors
																		, const Vocab &vocab
																		, const Moses::PhraseDictionary &phraseDict
																		, const std::vector<float> &weightT
																		, float weightWP
																		, const Moses::LMList &lmList
																		, const Moses::Phrase &sourcePhrase) const
{
	Moses::TargetPhrase *ret = new Moses::TargetPhrase(Moses::Output);
	
	// source phrase
	ret->SetSourcePhrase(&sourcePhrase);
	
	// words
	size_t phraseSize = GetSize();
	assert(phraseSize > 0); // last word is lhs
	--phraseSize;
	
	for (size_t pos = 0; pos < phraseSize; ++pos)
	{
		Moses::Word *mosesWord = GetWord(pos).ConvertToMoses(Moses::Output, outputFactors, vocab);
		ret->AddWord(*mosesWord);
		delete mosesWord;
	}
	
	// scores
	ret->SetScoreChart(phraseDict.GetFeature(), m_scores, weightT, lmList);
	
	// alignments
	std::list<std::pair<size_t, size_t> > alignmentInfo;
	for (size_t ind = 0; ind < m_align.size(); ++ind)
	{
		const std::pair<size_t, size_t> &entry = m_align[ind];
		alignmentInfo.push_back(entry);
	}
	ret->SetAlignmentInfo(alignmentInfo);
		
	Moses::Word *lhs = GetWord(GetSize() - 1).ConvertToMoses(Moses::Output, outputFactors, vocab);
	ret->SetTargetLHS(*lhs);
	delete lhs;
	
	return ret;		
}