本文整理汇总了C++中TargetPhraseCollection::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ TargetPhraseCollection::IsEmpty方法的具体用法?C++ TargetPhraseCollection::IsEmpty怎么用?C++ TargetPhraseCollection::IsEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TargetPhraseCollection
的用法示例。
在下文中一共展示了TargetPhraseCollection::IsEmpty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Add
void ChartTranslationOptionList::Add(const TargetPhraseCollection &tpc,
const StackVec &stackVec,
const WordsRange &range)
{
if (tpc.IsEmpty()) {
return;
}
for (size_t i = 0; i < stackVec.size(); ++i) {
const ChartCellLabel &chartCellLabel = *stackVec[i];
size_t numHypos = chartCellLabel.GetStack().cube->size();
if (numHypos == 0) {
return; // empty stack. These rules can't be used
}
}
float score = ChartTranslationOptions::CalcEstimateOfBestScore(tpc, stackVec);
// If the rule limit has already been reached then don't add the option
// unless it is better than at least one existing option.
if (m_size > m_ruleLimit && score < m_scoreThreshold) {
return;
}
// Add the option to the list.
if (m_size == m_collection.size()) {
// m_collection has reached capacity: create a new object.
m_collection.push_back(new ChartTranslationOptions(tpc, stackVec,
range, score));
} else {
// Overwrite an unused object.
*(m_collection[m_size]) = ChartTranslationOptions(tpc, stackVec,
range, score);
}
++m_size;
// If the rule limit hasn't been exceeded then update the threshold.
if (m_size <= m_ruleLimit) {
m_scoreThreshold = (score < m_scoreThreshold) ? score : m_scoreThreshold;
}
// Prune if bursting
if (m_size == m_ruleLimit * 2) {
NTH_ELEMENT4(m_collection.begin(),
m_collection.begin() + m_ruleLimit - 1,
m_collection.begin() + m_size,
ChartTranslationOptionOrderer());
m_scoreThreshold = m_collection[m_ruleLimit-1]->GetEstimateOfBestScore();
m_size = m_ruleLimit;
}
}
示例2: Add
void ChartTranslationOptionList::Add(const TargetPhraseCollection &tpc,
const StackVec &stackVec,
const WordsRange &range)
{
if (tpc.IsEmpty()) {
return;
}
float score = ChartTranslationOptions::CalcEstimateOfBestScore(tpc, stackVec);
// If the rule limit has already been reached then don't add the option
// unless it is better than at least one existing option.
if (m_size > m_ruleLimit && score < m_scoreThreshold) {
return;
}
// Add the option to the list.
if (m_size == m_collection.size()) {
// m_collection has reached capacity: create a new object.
m_collection.push_back(new ChartTranslationOptions(tpc, stackVec,
range, score));
} else {
// Overwrite an unused object.
*(m_collection[m_size]) = ChartTranslationOptions(tpc, stackVec,
range, score);
}
++m_size;
// If the rule limit hasn't been exceeded then update the threshold.
if (m_size <= m_ruleLimit) {
m_scoreThreshold = (score < m_scoreThreshold) ? score : m_scoreThreshold;
}
// Prune if bursting
if (m_size == m_ruleLimit * 2) {
std::nth_element(m_collection.begin(),
m_collection.begin() + m_ruleLimit - 1,
m_collection.begin() + m_size,
ChartTranslationOptionOrderer());
m_scoreThreshold = m_collection[m_ruleLimit-1]->GetEstimateOfBestScore();
m_size = m_ruleLimit;
}
}