本文整理汇总了C++中TargetPhraseCollection::end方法的典型用法代码示例。如果您正苦于以下问题:C++ TargetPhraseCollection::end方法的具体用法?C++ TargetPhraseCollection::end怎么用?C++ TargetPhraseCollection::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TargetPhraseCollection
的用法示例。
在下文中一共展示了TargetPhraseCollection::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TargetPhrase
TargetPhraseCollection::TargetPhraseCollection(const TargetPhraseCollection ©)
{
for (const_iterator iter = copy.begin(); iter != copy.end(); ++iter) {
const TargetPhrase &origTP = **iter;
TargetPhrase *newTP = new TargetPhrase(origTP);
Add(newTP);
}
}
示例2: ptr
ChartTranslationOptions::ChartTranslationOptions(const TargetPhraseCollection &targetPhraseColl,
const StackVec &stackVec,
const WordsRange &wordsRange,
float score)
: m_stackVec(stackVec)
, m_wordsRange(&wordsRange)
, m_estimateOfBestScore(score)
{
TargetPhraseCollection::const_iterator iter;
for (iter = targetPhraseColl.begin(); iter != targetPhraseColl.end(); ++iter) {
const TargetPhrase *origTP = *iter;
boost::shared_ptr<ChartTranslationOption> ptr(new ChartTranslationOption(*origTP));
m_collection.push_back(ptr);
}
}
示例3: Add
void ChartRuleCollection::Add(const TargetPhraseCollection &targetPhraseCollection
, const WordConsumed &wordConsumed
, bool adhereTableLimit
, size_t ruleLimit)
{
TargetPhraseCollection::const_iterator iter, iterEnd;
iterEnd = (!adhereTableLimit || ruleLimit == 0 || targetPhraseCollection.GetSize() < ruleLimit)
? targetPhraseCollection.end() : targetPhraseCollection.begin() + ruleLimit;
for (iter = targetPhraseCollection.begin(); iter != iterEnd; ++iter)
{
const TargetPhrase &targetPhrase = **iter;
float score = targetPhrase.GetFutureScore();
if (m_collection.size() < ruleLimit)
{ // not yet filled out quota. add everything
m_collection.push_back(new ChartRule(targetPhrase, wordConsumed));
m_scoreThreshold = (score < m_scoreThreshold) ? score : m_scoreThreshold;
}
else if (score > m_scoreThreshold)
{ // full but not bursting. add if better than worst score
m_collection.push_back(new ChartRule(targetPhrase, wordConsumed));
}
// prune if bursting
if (m_collection.size() > ruleLimit * 2)
{
std::nth_element(m_collection.begin()
, m_collection.begin() + ruleLimit
, m_collection.end()
, ChartRuleOrderer());
// delete the bottom half
for (size_t ind = ruleLimit; ind < m_collection.size(); ++ind)
{
// make the best score of bottom half the score threshold
const TargetPhrase &targetPhrase = m_collection[ind]->GetTargetPhrase();
float score = targetPhrase.GetFutureScore();
m_scoreThreshold = (score > m_scoreThreshold) ? score : m_scoreThreshold;
delete m_collection[ind];
}
m_collection.resize(ruleLimit);
}
}
}
示例4: edge
template <class Model> void Fill<Model>::Add(const TargetPhraseCollection &targets, const StackVec &nts, const WordsRange &)
{
std::vector<search::PartialVertex> vertices;
vertices.reserve(nts.size());
float below_score = 0.0;
for (StackVec::const_iterator i(nts.begin()); i != nts.end(); ++i) {
vertices.push_back((*i)->GetStack().incr->RootAlternate());
if (vertices.back().Empty()) return;
below_score += vertices.back().Bound();
}
std::vector<lm::WordIndex> words;
for (TargetPhraseCollection::const_iterator p(targets.begin()); p != targets.end(); ++p) {
words.clear();
const TargetPhrase &phrase = **p;
const AlignmentInfo::NonTermIndexMap &align = phrase.GetAlignNonTerm().GetNonTermIndexMap();
search::PartialEdge edge(edges_.AllocateEdge(nts.size()));
search::PartialVertex *nt = edge.NT();
for (size_t i = 0; i < phrase.GetSize(); ++i) {
const Word &word = phrase.GetWord(i);
if (word.IsNonTerminal()) {
*(nt++) = vertices[align[i]];
words.push_back(search::kNonTerminal);
} else {
words.push_back(Convert(word));
}
}
edge.SetScore(phrase.GetFutureScore() + below_score);
// prob and oov were already accounted for.
search::ScoreRule(context_.LanguageModel(), words, edge.Between());
search::Note note;
note.vp = &phrase;
edge.SetNote(note);
edges_.AddEdge(edge);
}
}