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


C++ Phrase类代码示例

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


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

示例1: MakeKey

std::string
LexicalReorderingTableMemory::MakeKey(const Phrase& f,
                                      const Phrase& e,
                                      const Phrase& c) const
{
  return MakeKey(auxClearString(f.GetStringRep(m_FactorsF)),
                 auxClearString(e.GetStringRep(m_FactorsE)),
                 auxClearString(c.GetStringRep(m_FactorsC)));
}
开发者ID:Deseaus,项目名称:mosesdecoder,代码行数:9,代码来源:LexicalReorderingTable.cpp

示例2: 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:hschreib,项目名称:mosesdecoder,代码行数:9,代码来源:Phrase.cpp

示例3: Word

Phrase::Phrase(const Phrase &copy)
  :m_words(copy.GetSize())
{
  for (size_t pos = 0; pos < copy.GetSize(); ++pos) {
    const Word &oldWord = copy.GetWord(pos);
    Word *newWord = new Word(oldWord);
    m_words[pos] = newWord;
  }
}
开发者ID:CUNI-Khresmoi,项目名称:CUNI-Khresmoi-Moses,代码行数:9,代码来源:Phrase.cpp

示例4: 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:CUNI-Khresmoi,项目名称:CUNI-Khresmoi-Moses,代码行数:9,代码来源:Phrase.cpp

示例5: makePhrase

//--------------------------------------------------------------
void testApp::makePhrase(string _p, int _v ){
    
    Phrase temp;
    pos.set( ofRandom(10, ofGetWidth() - font.stringWidth(_p) ) ,ofRandom(font.getLineHeight(), ofGetHeight() - font.getLineHeight() ));
    ofColor c = color.getColor( ofRandom(color.width), 50);
    temp.setup(_p, _v, &font, pos, &bg, c);
    phrases.push_back(temp);
    phrase = "";
    
}
开发者ID:piuggi,项目名称:letters,代码行数:11,代码来源:testApp.cpp

示例6: MakeKey

std::string
LexicalReorderingTableCompact::
MakeKey(const Phrase& f,
        const Phrase& e,
        const Phrase& c) const
{
  return MakeKey(Trim(f.GetStringRep(m_FactorsF)),
                 Trim(e.GetStringRep(m_FactorsE)),
                 Trim(c.GetStringRep(m_FactorsC)));
}
开发者ID:hschreib,项目名称:mosesdecoder,代码行数:10,代码来源:LexicalReorderingTableCompact.cpp

示例7: 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

示例8: PopulateWordVec

void AlignedSentence::PopulateWordVec(Phrase &vec, const std::string &line)
{
	std::vector<string> toks;
	Moses::Tokenize(toks, line);

	vec.resize(toks.size());
	for (size_t i = 0; i < vec.size(); ++i) {
		const string &tok = toks[i];
		Word *word = new Word(i, tok);
		vec[i] = word;
	}
}
开发者ID:840462307cn,项目名称:mosesdecoder,代码行数:12,代码来源:AlignedSentence.cpp

示例9: Phrase

void Manager::CreateInputPaths()
{
  for (size_t pos = 0; pos < m_sentence.GetSize(); ++pos) {
    Phrase *phrase = new Phrase(1);
    phrase->Set(0, m_sentence.GetWord(pos));

    InputPath *path = new InputPath(NULL, phrase, pos);
    m_inputPathQueue.push_back(path);

    CreateInputPaths(*path, pos + 1);
  }
}
开发者ID:arvs,项目名称:mosesdecoder,代码行数:12,代码来源:Manager.cpp

示例10: scorer

void KENLM<Model>::CalcScore(const Phrase<SCFG::Word> &phrase, float &fullScore,
                             float &ngramScore, std::size_t &oovCount) const
{
  fullScore = 0;
  ngramScore = 0;
  oovCount = 0;

  if (!phrase.GetSize()) return;

  lm::ngram::ChartState discarded_sadly;
  lm::ngram::RuleScore<Model> scorer(*m_ngram, discarded_sadly);

  size_t position;
  if (m_bos == phrase[0][m_factorType]) {
    scorer.BeginSentence();
    position = 1;
  } else {
    position = 0;
  }

  size_t ngramBoundary = m_ngram->Order() - 1;

  size_t end_loop = std::min(ngramBoundary, phrase.GetSize());
  for (; position < end_loop; ++position) {
    const SCFG::Word &word = phrase[position];
    if (word.isNonTerminal) {
      fullScore += scorer.Finish();
      scorer.Reset();
    } else {
      lm::WordIndex index = TranslateID(word);
      scorer.Terminal(index);
      if (!index) ++oovCount;
    }
  }
  float before_boundary = fullScore + scorer.Finish();
  for (; position < phrase.GetSize(); ++position) {
    const SCFG::Word &word = phrase[position];
    if (word.isNonTerminal) {
      fullScore += scorer.Finish();
      scorer.Reset();
    } else {
      lm::WordIndex index = TranslateID(word);
      scorer.Terminal(index);
      if (!index) ++oovCount;
    }
  }
  fullScore += scorer.Finish();

  ngramScore = TransformLMScore(fullScore - before_boundary);
  fullScore = TransformLMScore(fullScore);
}
开发者ID:a455bcd9,项目名称:mosesdecoder,代码行数:51,代码来源:KENLM.cpp

示例11: 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

示例12: MergeFactors

void Phrase::MergeFactors(const Phrase &copy)
{
  UTIL_THROW_IF2(GetSize() != copy.GetSize(), "Both phrases need to be the same size to merge");
  size_t size = GetSize();
  const size_t maxNumFactors = MAX_NUM_FACTORS;
  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:Deseaus,项目名称:mosesdecoder,代码行数:14,代码来源:Phrase.cpp

示例13: XMLParse

void AlignedSentenceSyntax::XMLParse(Phrase &output,
                                     SyntaxTree &tree,
                                     const pugi::xml_node &parentNode,
                                     const Parameter &params)
{
  int childNum = 0;
  for (pugi::xml_node childNode = parentNode.first_child(); childNode; childNode = childNode.next_sibling()) {
    string nodeName = childNode.name();

    // span label
    string label;
    int startPos = output.size();

    if (!nodeName.empty()) {
      pugi::xml_attribute attribute = childNode.attribute("label");
      label = attribute.as_string();

      // recursively call this function. For proper recursive trees
      XMLParse(output, tree, childNode, params);
    }



    // fill phrase vector
    string text = childNode.value();
    Escape(text);
    //cerr << childNum << " " << label << "=" << text << endl;

    std::vector<string> toks;
    Moses::Tokenize(toks, text);

    for (size_t i = 0; i < toks.size(); ++i) {
      const string &tok = toks[i];
      Word *word = new Word(output.size(), tok);
      output.push_back(word);
    }

    // is it a labelled span?
    int endPos = output.size() - 1;

    // fill syntax labels
    if (!label.empty()) {
      label = "[" + label + "]";
      tree.Add(startPos, endPos, label, params);
    }

    ++childNum;
  }

}
开发者ID:Deseaus,项目名称:mosesdecoder,代码行数:50,代码来源:AlignedSentenceSyntax.cpp

示例14: MergeFactors

void Phrase::MergeFactors(const Phrase &copy)
{
  CHECK(GetSize() == copy.GetSize());
  size_t size = GetSize();
  const size_t maxNumFactors = MAX_NUM_FACTORS;
  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:Kitton,项目名称:mosesdecoder,代码行数:14,代码来源:Phrase.cpp

示例15: MakeCacheKey

std::string LexicalReorderingTableTree::MakeCacheKey(const Phrase& f, 
						     const Phrase& e) const {
  std::string key;
  if(!m_FactorsF.empty()){
    key += auxClearString(f.GetStringRep(m_FactorsF));
  }
  if(!m_FactorsE.empty()){
    if(!key.empty()){
      key += "|||";
    }
    key += auxClearString(e.GetStringRep(m_FactorsE));
  }
  return key;
};
开发者ID:obo,项目名称:Moses-Extensions-at-UFAL,代码行数:14,代码来源:LexicalReorderingTable.cpp


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