本文整理汇总了C++中TIntV::PutAll方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntV::PutAll方法的具体用法?C++ TIntV::PutAll怎么用?C++ TIntV::PutAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntV
的用法示例。
在下文中一共展示了TIntV::PutAll方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMergedNmObj
void TNmObjBs::GetMergedNmObj(TIntV& NewNmObjIdV){
// matching constraints
int MnPfxLen=3; int MxSfxLen=2;
// create transformation vector
int NmObjs=NmObjWordStrVToDocIdVH.Len();
NewNmObjIdV.Gen(NmObjs); NewNmObjIdV.PutAll(-1);
// merging single words
// merging statistics
{int SingleWords=0; int ReducedSingleWords=0;
// collect single words according to prefix
TStrIntVH PfxStrToNmObjIdVH;
for (int NmObjId=0; NmObjId<NmObjs; NmObjId++){
if (NewNmObjIdV[NmObjId]!=-1){continue;}
const TStrV& WordStrV=NmObjWordStrVToDocIdVH.GetKey(NmObjId);
if (WordStrV.Len()==1){
TStr PfxStr=WordStrV[0].GetSubStr(0, 2);
PfxStrToNmObjIdVH.AddDat(PfxStr).Add(NmObjId);
SingleWords++;
}
}
// traverse word-groups with the same prefix
int Pfxs=PfxStrToNmObjIdVH.Len();
for (int PfxId=0; PfxId<Pfxs; PfxId++){
// get & traverse word-group
TIntV& NmObjIdV=PfxStrToNmObjIdVH[PfxId];
for (int NmObjIdN=0; NmObjIdN<NmObjIdV.Len(); NmObjIdN++){
int NmObjId=NmObjIdV[NmObjIdN];
if (NewNmObjIdV[NmObjId]!=-1){continue;}
NewNmObjIdV[NmObjId]=NmObjId;
const TStr& WordStr=NmObjWordStrVToDocIdVH.GetKey(NmObjId)[0];
int Fq=NmObjWordStrVToDocIdVH[NmObjId].Len();
TIntPrV FqNmObjIdPrV(NmObjIdV.Len(), 0);
FqNmObjIdPrV.Add(TIntPr(Fq, NmObjId));
// traverse rest of the word-group for matching words
for (int SubNmObjIdN=NmObjIdN+1; SubNmObjIdN<NmObjIdV.Len(); SubNmObjIdN++){
int SubNmObjId=NmObjIdV[SubNmObjIdN];
if (NewNmObjIdV[SubNmObjId]!=-1){continue;}
const TStr& SubWordStr=NmObjWordStrVToDocIdVH.GetKey(SubNmObjId)[0];
// test matching
if (IsMatchPfx(WordStr, SubWordStr, MnPfxLen, MxSfxLen)){
NewNmObjIdV[SubNmObjId]=NmObjId;
int SubFq=NmObjWordStrVToDocIdVH[SubNmObjId].Len();
FqNmObjIdPrV.Add(TIntPr(SubFq, SubNmObjId));
//printf("%s -> %s\n", WordStr.CStr(), SubWordStr.CStr());
}
}
// increment number of equivalence word-groups
ReducedSingleWords++;
// collapse matching words into most frequent word
if (FqNmObjIdPrV.Len()>1){
FqNmObjIdPrV.Sort(false);
int MainNmObjId=FqNmObjIdPrV[0].Val2;
NewNmObjIdV[MainNmObjId]=MainNmObjId;
TStr MainWordStr=NmObjWordStrVToDocIdVH.GetKey(MainNmObjId)[0];
//printf("[%s:", MainWordStr.CStr());
for (int FqNmObjIdPrN=1; FqNmObjIdPrN<FqNmObjIdPrV.Len(); FqNmObjIdPrN++){
int SubNmObjId=FqNmObjIdPrV[FqNmObjIdPrN].Val2;
NewNmObjIdV[SubNmObjId]=MainNmObjId;
//TStr& SubWordStr=NmObjWordStrVToDocIdVH.GetKey(SubNmObjId)[0];
//printf(" %s", SubWordStr.CStr());
}
//printf("]\n");
}
}
}
// print statistics
//printf("SingleWords:%d ReducedSingleWords:%d\n",
// SingleWords, ReducedSingleWords);
}
// merging double words
// merging statistics
{int DoubleWords=0; int ReducedDoubleWords=0;
// collect double words according to prefix
TStrIntVH PfxStrToNmObjIdVH;
for (int NmObjId=0; NmObjId<NmObjs; NmObjId++){
if (NewNmObjIdV[NmObjId]!=-1){continue;}
const TStrV& WordStrV=NmObjWordStrVToDocIdVH.GetKey(NmObjId);
if (WordStrV.Len()==2){
TStr PfxStr=WordStrV[0].GetSubStr(0, 2)+WordStrV[1].GetSubStr(0, 2);
PfxStrToNmObjIdVH.AddDat(PfxStr).Add(NmObjId);
DoubleWords++;
}
}
// traverse word-groups with the same prefix
int Pfxs=PfxStrToNmObjIdVH.Len();
for (int PfxId=0; PfxId<Pfxs; PfxId++){
// get & traverse word-group
TIntV& NmObjIdV=PfxStrToNmObjIdVH[PfxId];
for (int NmObjIdN=0; NmObjIdN<NmObjIdV.Len(); NmObjIdN++){
int NmObjId=NmObjIdV[NmObjIdN];
if (NewNmObjIdV[NmObjId]!=-1){continue;}
NewNmObjIdV[NmObjId]=NmObjId;
const TStr& WordStr1=NmObjWordStrVToDocIdVH.GetKey(NmObjId)[0];
const TStr& WordStr2=NmObjWordStrVToDocIdVH.GetKey(NmObjId)[1];
int Fq=NmObjWordStrVToDocIdVH[NmObjId].Len();
TIntPrV FqNmObjIdPrV(NmObjIdV.Len(), 0);
FqNmObjIdPrV.Add(TIntPr(Fq, NmObjId));
//.........这里部分代码省略.........