本文整理汇总了C++中Collector::Extend方法的典型用法代码示例。如果您正苦于以下问题:C++ Collector::Extend方法的具体用法?C++ Collector::Extend怎么用?C++ Collector::Extend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collector
的用法示例。
在下文中一共展示了Collector::Extend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAllTranslationOptions
translation_table_t PhraseTable::GetAllTranslationOptions(const vector<wid_t> &sentence, context_t *context) {
translation_table_t ttable;
for (size_t start = 0; start < sentence.size(); ++start) {
Collector *collector = self->index->NewCollector(context);
vector<wid_t> phrase;
vector<wid_t> phraseDelta;
for (size_t end = start; end < sentence.size(); ++end) {
wid_t word = sentence[end];
phrase.push_back(word);
phraseDelta.push_back(word);
if (ttable.find(phrase) == ttable.end()) {
vector<sample_t> samples;
collector->Extend(phraseDelta, self->numberOfSamples, samples);
phraseDelta.clear();
if (samples.empty())
break;
vector<TranslationOption> options;
MakeTranslationOptions(self->index, self->aligner, phrase, samples, options);
ttable[phrase] = options;
}
}
delete collector;
}
return ttable;
}
示例2: RunTest
void RunTest(SuffixArray &index, const context_t *context,
const unordered_map<vector<wid_t>, size_t, phrase_hash> &ngrams, vector<speed_perf_t> &speedData) {
size_t queryCount = 0;
for (auto entry = ngrams.begin(); entry != ngrams.end(); ++entry) {
Collector *collector = index.NewCollector(context, true);
for (size_t i = 0; i < entry->first.size(); ++i) {
double begin = GetTime();
vector<sample_t> samples;
collector->Extend(entry->first[i], 1000, samples);
speedData[i].seconds += GetElapsedTime(begin);
speedData[i].requests++;
queryCount++;
if (queryCount % 10000 == 0)
cout << "." << flush;
}
delete collector;
}
}