本文整理汇总了C++中alignment::get_head方法的典型用法代码示例。如果您正苦于以下问题:C++ alignment::get_head方法的具体用法?C++ alignment::get_head怎么用?C++ alignment::get_head使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alignment
的用法示例。
在下文中一共展示了alignment::get_head方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pow
void transpair_model4::computeScores(const alignment&al,vector<double>&d)const
{
LogProb total1 = 1.0,total2=1.0,total3=1.0,total4=1.0 ;
total1 *= pow(double(1-p1), m-2.0 * al.fert(0)) * pow(double(p1), double(al.fert(0)));
for (WordIndex i = 1 ; i <= al.fert(0) ; i++)
total1 *= double(m - al.fert(0) - i + 1) / (double(DeficientDistortionForEmptyWord?(max(2,int(m))/DeficientDistortionForEmptyWord):i)) ;
for (WordIndex i = 1 ; i <= l ; i++)
total2 *= get_fertility(i, al.fert(i));// * (LogProb) factorial(al.fert(i));
for (WordIndex j = 1 ; j <= m ; j++)
total3*= get_t(al(j), j) ;
for(WordIndex j=1;j<=m;j++)
if( al(j) )
if( al.get_head(al(j))==j)
{
int ep=al.prev_cept(al(j));
float x2=probFirst[ep](j,al.get_center(ep));
total4*=x2;
}
else
{
float x2=probSecond(j,al.prev_in_cept(j));
total4*=x2;
}
d.push_back(total1);//9
d.push_back(total2);//10
d.push_back(total3);//11
d.push_back(total4);//12
}
示例2: massert
LogProb transpair_model4::prob_of_target_and_alignment_given_source(const alignment&al, short distortionType,bool verb)const
{
LogProb total = 1.0 ;
static const LogProb almostZero = 1E-299 ;
if( distortionType&1 )
{
total *= prob_of_target_and_alignment_given_source_1(al,verb);
}
if( distortionType&2 )
{
for(WordIndex j=1;j<=m;j++)
if( al(j) )
if( al.get_head(al(j))==j)
{
int ep=al.prev_cept(al(j));
float x2=probFirst[ep](j,al.get_center(ep));
massert(x2<=1.0);
total*=x2;
if( verb) cerr << "IBM-4: d=1 of " << j << ": " << x2 << " -> " << total << endl;
}
else
{
float x2=probSecond(j,al.prev_in_cept(j));
massert(x2<=1.0);
total*=x2;
if( verb) cerr << "IBM-4: d>1 of " << j << ": " << x2 << " -> " << total << endl;
}
}
return total?total:almostZero;
}