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


C++ Sentence::GetSize方法代码示例

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


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

示例1: Cache

void LexicalReorderingTableTree::Cache(const Sentence& input){
  //only works with sentences...
  size_t prev_cache_size = m_Cache.size();
  size_t max_phrase_length = input.GetSize();
  for(size_t len = 0; len <= max_phrase_length; ++len){ 
	for(size_t start = 0; start+len <= input.GetSize(); ++start){
	  Phrase f    = input.GetSubString(WordsRange(start, start+len));
	  auxCacheForSrcPhrase(f);
	}
  }
  std::cerr << "Cached " << m_Cache.size() - prev_cache_size << " new primary reordering table keys\n"; 
}
开发者ID:obo,项目名称:Moses-Extensions-at-UFAL,代码行数:12,代码来源:LexicalReorderingTable.cpp

示例2: range

/** constructor; just initialize the base class */
TranslationOptionCollectionText::TranslationOptionCollectionText(Sentence const &input, size_t maxNoTransOptPerCoverage, float translationOptionThreshold)
  : TranslationOptionCollection(input, maxNoTransOptPerCoverage, translationOptionThreshold)
{
  size_t size = input.GetSize();
  m_inputPathMatrix.resize(size);
  for (size_t phaseSize = 1; phaseSize <= size; ++phaseSize) {
    for (size_t startPos = 0; startPos < size - phaseSize + 1; ++startPos) {
      size_t endPos = startPos + phaseSize -1;
      vector<InputPath*> &vec = m_inputPathMatrix[startPos];

      WordsRange range(startPos, endPos);
      Phrase subphrase(input.GetSubString(WordsRange(startPos, endPos)));
      const NonTerminalSet &labels = input.GetLabelSet(startPos, endPos);

      InputPath *node;
      if (range.GetNumWordsCovered() == 1) {
        node = new InputPath(subphrase, labels, range, NULL, NULL);
        vec.push_back(node);
      } else {
        const InputPath &prevNode = GetInputPath(startPos, endPos - 1);
        node = new InputPath(subphrase, labels, range, &prevNode, NULL);
        vec.push_back(node);
      }

      m_phraseDictionaryQueue.push_back(node);
    }
  }
}
开发者ID:Kitton,项目名称:mosesdecoder,代码行数:29,代码来源:TranslationOptionCollectionText.cpp

示例3: TargetPhrase

Manager::Manager(Sentence &sentence)
  :m_sentence(sentence)
  ,m_stacks(sentence.GetSize() + 1)
  ,m_emptyPhrase(new TargetPhrase(0))
  ,m_emptyRange(new WordsRange(NOT_FOUND, NOT_FOUND))
  ,m_emptyCoverage(new WordsBitmap(sentence.GetSize()))
{
  FeatureFunction::Initialize(m_sentence);

  Global &global = Global::InstanceNonConst();

  global.timer.check("Begin CreateInputPaths");
  CreateInputPaths();
  global.timer.check("Begin Lookup");
  Lookup();
  global.timer.check("Begin Search");
  Search();
  global.timer.check("Finished Search");
}
开发者ID:arvs,项目名称:mosesdecoder,代码行数:19,代码来源:Manager.cpp

示例4: ChangeSource

void SkeletonChangeInput::ChangeSource(InputType *&input) const
{
  // add factor[1] to each word. Created from first 4 letter of factor[0]

  Sentence *sentence = dynamic_cast<Sentence*>(input);
  UTIL_THROW_IF2(sentence == NULL, "Not a sentence input");

  FactorCollection &fc = FactorCollection::Instance();

  size_t size = sentence->GetSize();
  for (size_t i = 0; i < size; ++i) {
	  Word &word = sentence->Phrase::GetWord(i);
	  const Factor *factor0 = word[0];

	  std::string str = factor0->GetString().as_string();
	  if (str.length() > 4) {
  	    str = str.substr(0, 4);
	  }

	  const Factor *factor1 = fc.AddFactor(str);
	  word.SetFactor(1, factor1);
  }
}
开发者ID:840462307cn,项目名称:mosesdecoder,代码行数:23,代码来源:SkeletonChangeInput.cpp


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