本文整理汇总了C++中TargetPhrase::Create1AlignFromString方法的典型用法代码示例。如果您正苦于以下问题:C++ TargetPhrase::Create1AlignFromString方法的具体用法?C++ TargetPhrase::Create1AlignFromString怎么用?C++ TargetPhrase::Create1AlignFromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TargetPhrase
的用法示例。
在下文中一共展示了TargetPhrase::Create1AlignFromString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Tokenize
void Tokenize(SourcePhrase &sourcePhrase, TargetPhrase &targetPhrase, char *line, OnDiskWrapper &onDiskWrapper, int numScores, vector<float> &misc)
{
size_t scoreInd = 0;
// MAIN LOOP
size_t stage = 0;
/* 0 = source phrase
1 = target phrase
2 = scores
3 = align
4 = count
*/
char *tok = strtok (line," ");
while (tok != NULL)
{
if (0 == strcmp(tok, "|||"))
{
++stage;
}
else
{
switch (stage)
{
case 0:
{
Tokenize(sourcePhrase, tok, true, true, onDiskWrapper);
break;
}
case 1:
{
Tokenize(targetPhrase, tok, false, true, onDiskWrapper);
break;
}
case 2:
{
float score = Moses::Scan<float>(tok);
targetPhrase.SetScore(score, scoreInd);
++scoreInd;
break;
}
case 3:
{
targetPhrase.Create1AlignFromString(tok);
break;
}
case 4:
++stage;
break;
case 5:
{ // count info. Only store the 2nd one
float val = Moses::Scan<float>(tok);
misc[0] = val;
++stage;
break;
}
default:
assert(false);
break;
}
}
tok = strtok (NULL, " ");
} // while (tok != NULL)
assert(scoreInd == numScores);
targetPhrase.SortAlign();
} // Tokenize()