本文整理汇总了C++中TargetPhrase::GetRuleSource方法的典型用法代码示例。如果您正苦于以下问题:C++ TargetPhrase::GetRuleSource方法的具体用法?C++ TargetPhrase::GetRuleSource怎么用?C++ TargetPhrase::GetRuleSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TargetPhrase
的用法示例。
在下文中一共展示了TargetPhrase::GetRuleSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EvaluateWithSourceContext
void SpanLength::EvaluateWithSourceContext(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, const StackVec *stackVec
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedFutureScore) const
{
assert(stackVec);
const PhraseProperty *property = targetPhrase.GetProperty("SpanLength");
if (property == NULL) {
return;
}
const SpanLengthPhraseProperty *slProp = static_cast<const SpanLengthPhraseProperty*>(property);
const Phrase *ruleSource = targetPhrase.GetRuleSource();
assert(ruleSource);
float score = 0;
for (size_t i = 0; i < stackVec->size(); ++i) {
const ChartCellLabel &cell = *stackVec->at(i);
const WordsRange &ntRange = cell.GetCoverage();
size_t sourceWidth = ntRange.GetNumWordsCovered();
float prob = slProp->GetProb(i, sourceWidth, m_const);
score += TransformScore(prob);
}
if (score < -100.0f) {
float weight = StaticData::Instance().GetWeight(this);
if (weight < 0) {
score = -100;
}
}
scoreBreakdown.PlusEquals(this, score);
}
示例2: EvaluateWithSourceContext
void MaxSpanFreeNonTermSource::EvaluateWithSourceContext(const InputType &input
, const InputPath &inputPath
, const TargetPhrase &targetPhrase
, const StackVec *stackVec
, ScoreComponentCollection &scoreBreakdown
, ScoreComponentCollection *estimatedScores) const
{
const Word &targetLHS = targetPhrase.GetTargetLHS();
if (targetLHS == m_glueTargetLHS) {
// don't delete glue rules
return;
}
const Phrase *source = targetPhrase.GetRuleSource();
assert(source);
float score = 0;
if (source->Front().IsNonTerminal()) {
const ChartCellLabel &cell = *stackVec->front();
if (cell.GetCoverage().GetNumWordsCovered() > m_maxSpan) {
score = - std::numeric_limits<float>::infinity();
}
}
if (source->Back().IsNonTerminal()) {
const ChartCellLabel &cell = *stackVec->back();
if (cell.GetCoverage().GetNumWordsCovered() > m_maxSpan) {
score = - std::numeric_limits<float>::infinity();
}
}
scoreBreakdown.PlusEquals(this, score);
}