예제 #1
0
Moses::Word *Word::ConvertToMoses(Moses::FactorDirection direction
														, const std::vector<Moses::FactorType> &outputFactorsVec
														, const Vocab &vocab) const
{
	Moses::Word *ret = new Moses::Word(m_isNonTerminal);
	
	for (size_t ind = 0; ind < m_factors.size(); ++ind)
	{
		Moses::FactorType factorType = outputFactorsVec[ind];
		UINT32 vocabId = m_factors[ind];
		const Moses::Factor *factor = vocab.GetFactor(vocabId, factorType, direction, m_isNonTerminal);
		ret->SetFactor(factorType, factor);
	}
	
	return ret;
	
}
예제 #2
0
Moses::Word *Word::ConvertToMoses(Moses::FactorDirection direction
                                  , const std::vector<Moses::FactorType> &outputFactorsVec
                                  , const Vocab &vocab) const
{
  Moses::FactorCollection &factorColl = Moses::FactorCollection::Instance();
  Moses::Word *ret = new Moses::Word(m_isNonTerminal);

  const string &str = vocab.GetString(m_vocabId);
  vector<string> toks = Moses::Tokenize(str, "|");
  for (size_t ind = 0; ind < toks.size(); ++ind) {
    Moses::FactorType factorType = outputFactorsVec[ind];
    const Moses::Factor *factor = factorColl.AddFactor(direction, factorType, toks[ind]);
    ret->SetFactor(factorType, factor);
  }

  return ret;

}
예제 #3
0
파일: Word.cpp 프로젝트: Avmb/mosesdecoder
void Word::ConvertToMoses(
    const std::vector<Moses::FactorType> &outputFactorsVec, 
    const Vocab &vocab,
    Moses::Word &overwrite) const {
  Moses::FactorCollection &factorColl = Moses::FactorCollection::Instance();
  overwrite = Moses::Word(m_isNonTerminal);

  // TODO: this conversion should have been done at load time.  
  util::TokenIter<util::SingleCharacter> tok(vocab.GetString(m_vocabId), '|');

  for (std::vector<Moses::FactorType>::const_iterator t = outputFactorsVec.begin(); t != outputFactorsVec.end(); ++t, ++tok) {
    UTIL_THROW_IF(!tok, util::Exception, "Too few factors in \"" << vocab.GetString(m_vocabId) << "\"; was expecting " << outputFactorsVec.size());
    overwrite.SetFactor(*t, factorColl.AddFactor(*tok));
  }
  UTIL_THROW_IF(tok, util::Exception, "Too many factors in \"" << vocab.GetString(m_vocabId) << "\"; was expecting " << outputFactorsVec.size());
}