当前位置: 首页>>代码示例>>C++>>正文


C++ Phrase::GetFactor方法代码示例

本文整理汇总了C++中Phrase::GetFactor方法的典型用法代码示例。如果您正苦于以下问题:C++ Phrase::GetFactor方法的具体用法?C++ Phrase::GetFactor怎么用?C++ Phrase::GetFactor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phrase的用法示例。


在下文中一共展示了Phrase::GetFactor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OutputSurface

/***
 * print surface factor only for the given phrase
 */
void BaseManager::OutputSurface(std::ostream &out, const Phrase &phrase,
                                const std::vector<FactorType> &outputFactorOrder,
                                bool reportAllFactors) const
{
  UTIL_THROW_IF2(outputFactorOrder.size() == 0,
                 "Cannot be empty phrase");
  if (reportAllFactors == true) {
    out << phrase;
  } else {
    size_t size = phrase.GetSize();
    for (size_t pos = 0 ; pos < size ; pos++) {
      const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[0]);
      out << *factor;
      UTIL_THROW_IF2(factor == NULL,
                     "Empty factor 0 at position " << pos);

      for (size_t i = 1 ; i < outputFactorOrder.size() ; i++) {
        const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[i]);
        UTIL_THROW_IF2(factor == NULL,
                       "Empty factor " << i << " at position " << pos);

        out << "|" << *factor;
      }
      out << " ";
    }
  }
}
开发者ID:Jivt,项目名称:mosesdecoder,代码行数:30,代码来源:BaseManager.cpp

示例2: outputHypo

    void outputHypo(ostream& out, const Hypothesis* hypo, bool addAlignmentInfo, vector<xmlrpc_c::value>& alignInfo, bool reportAllFactors = false) {
        if (hypo->GetPrevHypo() != NULL) {
            outputHypo(out,hypo->GetPrevHypo(),addAlignmentInfo, alignInfo, reportAllFactors);
            Phrase p = hypo->GetCurrTargetPhrase();
            if(reportAllFactors) {
                out << p << " ";
            } else {
                for (size_t pos = 0 ; pos < p.GetSize() ; pos++) {
                    const Factor *factor = p.GetFactor(pos, 0);
                    out << *factor << " ";
                }
            }

            if (addAlignmentInfo) {
                /**
                 * Add the alignment info to the array. This is in target order and consists of
                 *       (tgt-start, src-start, src-end) triples.
                 **/
                map<string, xmlrpc_c::value> phraseAlignInfo;
                phraseAlignInfo["tgt-start"] = xmlrpc_c::value_int(hypo->GetCurrTargetWordsRange().GetStartPos());
                phraseAlignInfo["src-start"] = xmlrpc_c::value_int(hypo->GetCurrSourceWordsRange().GetStartPos());
                phraseAlignInfo["src-end"] = xmlrpc_c::value_int(hypo->GetCurrSourceWordsRange().GetEndPos());
                alignInfo.push_back(xmlrpc_c::value_struct(phraseAlignInfo));
            }
        }
    }
开发者ID:junfeiguo,项目名称:mosesdecoder,代码行数:26,代码来源:mosesserver.cpp

示例3: MergeFactors

void Phrase::MergeFactors(const Phrase &copy, const std::vector<FactorType>& factorVec)
{
  CHECK(GetSize() == copy.GetSize());
  for (size_t currPos = 0 ; currPos < GetSize() ; currPos++)
    for (std::vector<FactorType>::const_iterator i = factorVec.begin();
         i != factorVec.end(); ++i) {
      SetFactor(currPos, *i, copy.GetFactor(currPos, *i));
    }
}
开发者ID:Kitton,项目名称:mosesdecoder,代码行数:9,代码来源:Phrase.cpp

示例4: MergeFactors

void Phrase::MergeFactors(const Phrase &copy, const std::vector<FactorType>& factorVec)
{
  UTIL_THROW_IF2(GetSize() != copy.GetSize(), "Both phrases need to be the same size to merge");
  for (size_t currPos = 0 ; currPos < GetSize() ; currPos++)
    for (std::vector<FactorType>::const_iterator i = factorVec.begin();
         i != factorVec.end(); ++i) {
      SetFactor(currPos, *i, copy.GetFactor(currPos, *i));
    }
}
开发者ID:Deseaus,项目名称:mosesdecoder,代码行数:9,代码来源:Phrase.cpp

示例5: OutputSurface

/***
 * print surface factor only for the given phrase
 */
void OutputSurface(std::ostream &out, const Phrase &phrase, const std::vector<FactorType> &outputFactorOrder, bool reportAllFactors)
{
  CHECK(outputFactorOrder.size() > 0);
  if (reportAllFactors == true) {
    out << phrase;
  } else {
    size_t size = phrase.GetSize();
    for (size_t pos = 0 ; pos < size ; pos++) {
      const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[0]);
      out << *factor;

      for (size_t i = 1 ; i < outputFactorOrder.size() ; i++) {
        const Factor *factor = phrase.GetFactor(pos, outputFactorOrder[i]);
        out << "|" << *factor;
      }
      out << " ";
    }
  }
}
开发者ID:MarwenAZOUZI,项目名称:mosesdecoder,代码行数:22,代码来源:IOWrapper.cpp

示例6: IsCompatible

bool Phrase::IsCompatible(const Phrase &inputPhrase, FactorType factorType) const
{
	if (inputPhrase.GetSize() != GetSize())	{ return false;	}
	for (size_t currPos = 0 ; currPos < GetSize() ; currPos++)
	{
		if (GetFactor(currPos, factorType) != inputPhrase.GetFactor(currPos, factorType))
			return false;
	}
	return true;
}
开发者ID:poetzhangzi,项目名称:test,代码行数:10,代码来源:Phrase.cpp

示例7: IsCompatible

bool Phrase::IsCompatible(const Phrase &inputPhrase, const std::vector<FactorType>& factorVec) const
{
  if (inputPhrase.GetSize() != GetSize())	{
    return false;
  }
  for (size_t currPos = 0 ; currPos < GetSize() ; currPos++) {
    for (std::vector<FactorType>::const_iterator i = factorVec.begin();
         i != factorVec.end(); ++i) {
      if (GetFactor(currPos, *i) != inputPhrase.GetFactor(currPos, *i))
        return false;
    }
  }
  return true;
}
开发者ID:Deseaus,项目名称:mosesdecoder,代码行数:14,代码来源:Phrase.cpp

示例8: MergeFactors

void Phrase::MergeFactors(const Phrase &copy)
{
  assert(GetSize() == copy.GetSize());
  size_t size = GetSize();
  const size_t maxNumFactors = StaticData::Instance().GetMaxNumFactors(this->GetDirection());
  for (size_t currPos = 0 ; currPos < size ; currPos++) {
    for (unsigned int currFactor = 0 ; currFactor < maxNumFactors ; currFactor++) {
      FactorType factorType = static_cast<FactorType>(currFactor);
      const Factor *factor = copy.GetFactor(currPos, factorType);
      if (factor != NULL)
        SetFactor(currPos, factorType, factor);
    }
  }
}
开发者ID:fancycheung,项目名称:ondrej-test-project-1,代码行数:14,代码来源:Phrase.cpp

示例9: GetSurfacePhrase

Phrase TrellisPath::GetSurfacePhrase() const
{
  const std::vector<FactorType> &outputFactor = StaticData::Instance().GetOutputFactorOrder();
  Phrase targetPhrase = GetTargetPhrase()
                        ,ret(targetPhrase.GetSize());

  for (size_t pos = 0 ; pos < targetPhrase.GetSize() ; ++pos) {
    Word &newWord = ret.AddWord();
    for (size_t i = 0 ; i < outputFactor.size() ; i++) {
      FactorType factorType = outputFactor[i];
      const Factor *factor = targetPhrase.GetFactor(pos, factorType);
      CHECK(factor);
      newWord[factorType] = factor;
    }
  }

  return ret;
}
开发者ID:lolobaro,项目名称:mosesdecoder-stackrescore,代码行数:18,代码来源:TrellisPath.cpp

示例10: GetSurfacePhrase

Phrase TrellisPath::GetSurfacePhrase() const
{
  std::vector<FactorType> const& oFactor = manager().options()->output.factor_order;
  Phrase targetPhrase = GetTargetPhrase();
  Phrase ret(targetPhrase.GetSize());

  for (size_t pos = 0 ; pos < targetPhrase.GetSize() ; ++pos) {
    Word &newWord = ret.AddWord();
    for (size_t i = 0 ; i < oFactor.size() ; i++) {
      FactorType factorType = oFactor[i];
      const Factor *factor = targetPhrase.GetFactor(pos, factorType);
      UTIL_THROW_IF2(factor == NULL,
                     "No factor " << factorType << " at position " << pos);
      newWord[factorType] = factor;
    }
  }

  return ret;
}
开发者ID:mitramah,项目名称:mosesdecoder,代码行数:19,代码来源:TrellisPath.cpp


注:本文中的Phrase::GetFactor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。