当前位置: 首页>>代码示例>>C++>>正文


C++ TIntV::Reserve方法代码示例

本文整理汇总了C++中TIntV::Reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntV::Reserve方法的具体用法?C++ TIntV::Reserve怎么用?C++ TIntV::Reserve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TIntV的用法示例。


在下文中一共展示了TIntV::Reserve方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DocStrToWIdV

//////////////////////////////////////////////////////////////////////////
// String-To-Words
void TStrParser::DocStrToWIdV(const TStr& _DocStr, TIntV& WordIdV, const bool& Stemm) {
    TStr DocStr = _DocStr.GetUc();  // to upper case
    TStrV WordV; DocStr.SplitOnWs(WordV); int WordN = WordV.Len();
    WordIdV.Reserve(WordN, 0);

    PStemmer Stemmer = TStemmer::New(stmtPorter);
    TIntH WordsInDoc;
    for (int WordC = 0; WordC < WordN; WordC++) {
        TStr WordStr;
        if (Stemm) {
            WordStr = Stemmer->GetStem(WordV[WordC]);
        } else {
            WordStr = WordV[WordC];
        }
        int WId = GetWId(WordStr);
        if (WId == -1) {
            WId = WordToIdH.AddKey(WordStr);
            WordToIdH[WId] = 0;
        }
        WordIdV.Add(WId);
        
        // is it first time we see this word in this doc?
        if (!WordsInDoc.IsKey(WId)) WordsInDoc.AddKey(WId);
    }

    //do some statistics for DF
    DocsParsed++;
    for (int i = 0, l = WordsInDoc.Len(); i < l; i++)
        WordToIdH[WordsInDoc.GetKey(i)]++;

    Assert(WordV.Len() == WordIdV.Len());
}
开发者ID:Austindeadhead,项目名称:qminer,代码行数:34,代码来源:strkernel.cpp

示例2: GetSubValV

TUStr TUStr::GetSubValV(const int& BChN, const int& EChN){
	//size_t Len = EChN - BChN + 1;
	TIntV UniChV; 
	int capacity = BChN - EChN + 1;
	if(capacity < this->UniChV.Reserved()){
		UniChV.Reserve(BChN - EChN + 1, 0);
	}
	this->UniChV.GetSubValV(BChN, EChN, UniChV);
	return TUStr(UniChV);
}
开发者ID:josthkko,项目名称:qminer,代码行数:10,代码来源:unicodestring.cpp

示例3: GetWordBoundPV

void TUStr::GetWordBoundPV(TIntV& WordBoundPosV){
  TBoolV WordBoundPV;
  TUnicodeDef::GetDef()->FindWordBoundaries(UniChV, WordBoundPV);
  int n = WordBoundPV.Len();
  WordBoundPosV.Reserve(n);
  for(int i = 0; i <= n; i++){
	  if(WordBoundPV[i]){
		WordBoundPosV.Add(i);
	  }
  }
}
开发者ID:josthkko,项目名称:qminer,代码行数:11,代码来源:unicodestring.cpp

示例4: DocStrToChIdV

void TStrParser::DocStrToChIdV(const TStr& _DocStr, TIntV& ChIdV) {
    TStr DocStr = _DocStr.GetUc();  // to upper case
    int ChN = DocStr.Len();
    ChIdV.Reserve(ChN, 0);
    for (int ChC = 0; ChC < ChN; ChC++) {
        TStr ChStr = DocStr.GetSubStr(ChC,ChC);
        int ChId = GetWId(ChStr);
        if (ChId != -1) {
            WordToIdH[ChId]++;
        } else {
            ChId = WordToIdH.AddKey(ChStr);
            WordToIdH[ChId] = 1;
        }
        ChIdV.Add(ChId);
    }
}
开发者ID:Austindeadhead,项目名称:qminer,代码行数:16,代码来源:strkernel.cpp


注:本文中的TIntV::Reserve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。