本文整理汇总了C++中WordsBitmap::SetValue方法的典型用法代码示例。如果您正苦于以下问题:C++ WordsBitmap::SetValue方法的具体用法?C++ WordsBitmap::SetValue怎么用?C++ WordsBitmap::SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WordsBitmap
的用法示例。
在下文中一共展示了WordsBitmap::SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Expand
LexicalReorderingState* HierarchicalReorderingForwardState::Expand(const TranslationOption& topt, Scores& scores) const {
const LexicalReorderingConfiguration::ModelType modelType = m_configuration.GetModelType();
const WordsRange currWordsRange = topt.GetSourceWordsRange();
// keep track of the current coverage ourselves so we don't need the hypothesis
WordsBitmap coverage = m_coverage;
coverage.SetValue(currWordsRange.GetStartPos(), currWordsRange.GetEndPos(), true);
ReorderingType reoType;
if (m_first) {
ClearScores(scores);
} else {
if (modelType == LexicalReorderingConfiguration::MSD) {
reoType = GetOrientationTypeMSD(currWordsRange, coverage);
} else if (modelType == LexicalReorderingConfiguration::MSLR) {
reoType = GetOrientationTypeMSLR(currWordsRange, coverage);
} else if (modelType == LexicalReorderingConfiguration::Monotonic) {
reoType = GetOrientationTypeMonotonic(currWordsRange, coverage);
} else {
reoType = GetOrientationTypeLeftRight(currWordsRange, coverage);
}
CopyScores(scores, topt, reoType);
}
return new HierarchicalReorderingForwardState(this, topt);
}
示例2: Evaluate
FFState* OpSequenceModel::Evaluate(
const Hypothesis& cur_hypo,
const FFState* prev_state,
ScoreComponentCollection* accumulator) const
{
const TargetPhrase &target = cur_hypo.GetCurrTargetPhrase();
const WordsBitmap &bitmap = cur_hypo.GetWordsBitmap();
WordsBitmap myBitmap = bitmap;
const Manager &manager = cur_hypo.GetManager();
const InputType &source = manager.GetSource();
const Sentence &sourceSentence = static_cast<const Sentence&>(source);
osmHypothesis obj;
vector <string> mySourcePhrase;
vector <string> myTargetPhrase;
vector<float> scores;
//target.GetWord(0)
//cerr << target <<" --- "<<target.GetSourcePhrase()<< endl; // English ...
//cerr << align << endl; // Alignments ...
//cerr << cur_hypo.GetCurrSourceWordsRange() << endl;
//cerr << source <<endl;
// int a = sourceRange.GetStartPos();
// cerr << source.GetWord(a);
//cerr <<a<<endl;
//const Sentence &sentence = static_cast<const Sentence&>(curr_hypo.GetManager().GetSource());
const WordsRange & sourceRange = cur_hypo.GetCurrSourceWordsRange();
int startIndex = sourceRange.GetStartPos();
int endIndex = sourceRange.GetEndPos();
const AlignmentInfo &align = cur_hypo.GetCurrTargetPhrase().GetAlignTerm();
osmState * statePtr;
vector <int> alignments;
AlignmentInfo::const_iterator iter;
for (iter = align.begin(); iter != align.end(); ++iter) {
//cerr << iter->first << "----" << iter->second << " ";
alignments.push_back(iter->first);
alignments.push_back(iter->second);
}
//cerr<<bitmap<<endl;
//cerr<<startIndex<<" "<<endIndex<<endl;
for (int i = startIndex; i <= endIndex; i++) {
myBitmap.SetValue(i,0); // resetting coverage of this phrase ...
mySourcePhrase.push_back(source.GetWord(i).GetFactor(sFactor)->GetString().as_string());
// cerr<<mySourcePhrase[i]<<endl;
}
for (int i = 0; i < target.GetSize(); i++) {
if (target.GetWord(i).IsOOV() && sFactor == 0 && tFactor == 0)
myTargetPhrase.push_back("_TRANS_SLF_");
else
myTargetPhrase.push_back(target.GetWord(i).GetFactor(tFactor)->GetString().as_string());
}
//cerr<<myBitmap<<endl;
obj.setState(prev_state);
obj.constructCepts(alignments,startIndex,endIndex,target.GetSize());
obj.setPhrases(mySourcePhrase , myTargetPhrase);
obj.computeOSMFeature(startIndex,myBitmap);
obj.calculateOSMProb(*OSM);
obj.populateScores(scores,numFeatures);
//obj.print();
/*
if (bitmap.GetFirstGapPos() == NOT_FOUND)
{
int xx;
cerr<<bitmap<<endl;
int a = bitmap.GetFirstGapPos();
obj.print();
cin>>xx;
}
*/
accumulator->PlusEquals(this, scores);
return obj.saveState();
//.........这里部分代码省略.........
示例3: if
void osmHypothesis :: generateOperations(int & startIndex , int j1 , int contFlag , WordsBitmap & coverageVector , string english , string german , set <int> & targetNullWords , vector <string> & currF)
{
int gFlag = 0;
int gp = 0;
int ans;
if ( j < j1) // j1 is the index of the source word we are about to generate ...
{
//if(coverageVector[j]==0) // if source word at j is not generated yet ...
if(coverageVector.GetValue(j)==0) // if source word at j is not generated yet ...
{
operations.push_back("_INS_GAP_");
gFlag++;
gap[j]="Unfilled";
}
if (j == E)
{
j = j1;
}
else
{
operations.push_back("_JMP_FWD_");
j=E;
}
}
if (j1 < j)
{
// if(j < E && coverageVector[j]==0)
if(j < E && coverageVector.GetValue(j)==0)
{
operations.push_back("_INS_GAP_");
gFlag++;
gap[j]="Unfilled";
}
j=closestGap(gap,j1,gp);
operations.push_back("_JMP_BCK_"+ intToString(gp));
//cout<<"I am j "<<j<<endl;
//cout<<"I am j1 "<<j1<<endl;
if(j==j1)
gap[j]="Filled";
}
if (j < j1)
{
operations.push_back("_INS_GAP_");
gap[j] = "Unfilled";
gFlag++;
j=j1;
}
if(contFlag == 0) // First words of the multi-word cept ...
{
if(english == "_TRANS_SLF_") // Unknown word ...
{
operations.push_back("_TRANS_SLF_");
}
else
{
operations.push_back("_TRANS_" + english + "_TO_" + german);
}
//ans = firstOpenGap(coverageVector);
ans = coverageVector.GetFirstGapPos();
if (ans != -1)
gapWidth += j - ans;
}
else if (contFlag == 2)
{
operations.push_back("_INS_" + german);
ans = coverageVector.GetFirstGapPos();
if (ans != -1)
gapWidth += j - ans;
deletionCount++;
}
else
{
operations.push_back("_CONT_CEPT_");
}
//coverageVector[j]=1;
coverageVector.SetValue(j,1);
j+=1;
if(E<j)
E=j;
if (gFlag > 0)
gapCount++;
//.........这里部分代码省略.........