本文整理汇总了C++中TStrV类的典型用法代码示例。如果您正苦于以下问题:C++ TStrV类的具体用法?C++ TStrV怎么用?C++ TStrV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TStrV类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EscapableHandleScope
v8::Local<v8::Value> TNodeJsUtil::GetStrArr(const TStrV& StrV) {
v8::Isolate* Isolate = v8::Isolate::GetCurrent();
v8::EscapableHandleScope EscapableHandleScope(Isolate);
v8::Local<v8::Array> JsStrV = v8::Array::New(Isolate, StrV.Len());
for (int StrN = 0; StrN < StrV.Len(); StrN++) {
JsStrV->Set(StrN, v8::String::NewFromUtf8(Isolate, StrV[StrN].CStr()));
}
return EscapableHandleScope.Escape(JsStrV);
}
示例2: while
int TTransCorpus::CountWords(const TIntStrH& StrH) {
int Words = 0, KeyId = StrH.FFirstKeyId();
while (StrH.FNextKeyId(KeyId)) {
const TStr& Str = StrH[KeyId];
TStrV WordV; Str.SplitOnWs(WordV);
Words += WordV.Len();
}
return Words;
}
示例3: LoadFromFile
void TSwSet::LoadFromFile(const TStr& FNm) {
TStr FileStr = TStr::LoadTxt(FNm);
FileStr.DelChAll('\r');
TStrV WordV; FileStr.SplitOnAllCh('\n', WordV);
for (int WordN = 0; WordN < WordV.Len(); WordN++) {
const TStr& WordStr = WordV[WordN];
if (!IsIn(WordStr)) { AddWord(WordStr); }
}
}
示例4: DelWc
void TFile::DelWc(const TStr& WcStr, const bool& RecurseDirP){
// collect file-names
TStrV FNmV;
TFFile FFile(WcStr, RecurseDirP); TStr FNm;
while (FFile.Next(FNm)){
FNmV.Add(FNm);}
// delete files
for (int FNmN=0; FNmN<FNmV.Len(); FNmN++){
Del(FNmV[FNmN], false);}
}
示例5: GetVoidItemIdV
void TAmazonItemBs::GetVoidItemIdV(TStrV& VoidItemIdV) const {
VoidItemIdV.Clr();
for (int ItemIdN=0; ItemIdN<GetItems(); ItemIdN++){
PAmazonItem Item=GetItem(ItemIdN);
for (int NextItemIdN=0; NextItemIdN<Item->GetNextItemIds(); NextItemIdN++){
TStr NextItemId=Item->GetNextItemId(NextItemIdN);
if (!IsItem(NextItemId)){VoidItemIdV.AddUnique(NextItemId);}
}
}
}
示例6: TStrV
TStrV TTable::GetEdgeStrAttrV() const {
TStrV StrEA = TStrV(StrColMaps.Len(),0);
for (int i = 0; i < EdgeAttrV.Len(); i++) {
TStr Attr = EdgeAttrV[i];
if (GetColType(Attr) == STR) {
StrEA.Add(Attr);
}
}
return StrEA;
}
示例7: GetBackupFolders
// return the list of folders containing backups for a given profile name
// folders are sorted from the oldest to the newest
void TFolderBackup::GetBackupFolders(const TStr& ProfileName, TStrV& FolderNmV) const
{
FolderNmV.Clr();
if (ProfileH.IsKey(ProfileName)) {
TBackupProfile Profile = ProfileH.GetDat(ProfileName);
const TVec<TBackupLogInfo>& LogV = Profile.GetLogs();
for (int N = 0; N < LogV.Len(); N++)
FolderNmV.Add(LogV[N].GetFolderName());
}
}
示例8: GetNGramStrV
void TNGramBs::GetNGramStrV(
const TStr& HtmlStr, TStrV& NGramStrV, TIntPrV& NGramBEChXPrV) const {
TIntV NGramIdV; NGramStrV.Clr(); NGramBEChXPrV.Clr();
TNGramBs::GetNGramIdV(HtmlStr, NGramIdV, NGramBEChXPrV);
NGramStrV.Gen(NGramIdV.Len(), 0);
for (int NGramIdN=0; NGramIdN<NGramIdV.Len(); NGramIdN++){
TStr NGramStr=GetNGramStr(NGramIdV[NGramIdN]);
NGramStrV.Add(NGramStr);
}
}
示例9: GetObjHdNmV
void TExpHelp::GetObjHdNmV(const TStr& CatNm, TStrV& ObjHdNmV) const {
ObjHdNmV.Clr();
for (int ObjN=0; ObjN<ObjV.Len(); ObjN++){
TStr ObjCatNm=ObjV[ObjN]->GetCatNm();
TStr ObjHdNm=ObjV[ObjN]->GetHdItem()->GetNm();
if ((CatNm.Empty())||(CatNm=="All")||(CatNm==ObjCatNm)){
ObjHdNmV.AddUnique(ObjHdNm);}
}
ObjHdNmV.Sort();
}
示例10: FFile
PBowDocBs TBowFl::LoadReuters21578Txt(
const TStr& FPath, const int& MxDocs,
const TStr& SwSetTypeNm, const TStr& StemmerTypeNm,
const int& MxNGramLen, const int& MnNGramFq, const bool& SaveDocP,
const PNotify& Notify){
// prepare stop-words
PSwSet SwSet=TSwSet::GetSwSet(SwSetTypeNm);
// prepare stemmer
PStemmer Stemmer=TStemmer::GetStemmer(StemmerTypeNm);
// create ngrams
PNGramBs NGramBs;
if (!((MxNGramLen==1)&&(MnNGramFq==1))){
NGramBs=TNGramBs::GetNGramBsFromReuters21578(
FPath, MxDocs,
MxNGramLen, MnNGramFq, SwSet, Stemmer);
}
// create document-base
PBowDocBs BowDocBs=TBowDocBs::New(SwSet, Stemmer, NGramBs);
// traverse directory
TFFile FFile(FPath, ".SGM", false); TStr FNm; int Docs=0;
while (FFile.Next(FNm)){
printf("Processing file '%s'\n", FNm.CStr());
TIntH DocWIdToFqH(100);
TXmlDocV LDocV; TXmlDoc::LoadTxt(FNm, LDocV);
for (int LDocN=0; LDocN<LDocV.Len(); LDocN++){
Docs++; if (Docs%100==0){printf("%d\r", Docs);}
if ((MxDocs!=-1)&&(Docs>=MxDocs)){break;}
// get document-name
PXmlDoc Doc=LDocV[LDocN];
PXmlTok DocTok=Doc->GetTok();
TStr DocNm=DocTok->GetArgVal("NEWID");
// get document-categories
TStrV CatNmV;
TXmlTokV TopicsTokV; Doc->GetTagTokV("REUTERS|TOPICS|D", TopicsTokV);
for (int TopicsTokN=0; TopicsTokN<TopicsTokV.Len(); TopicsTokN++){
TStr CatNm=TopicsTokV[TopicsTokN]->GetTokStr(false);
CatNmV.Add(CatNm);
}
// get document-contents
PXmlTok DocStrTok=Doc->GetTagTok("REUTERS|TEXT");
TStr DocStr=DocStrTok->GetTokStr(false);
// add document to bow
int DId=BowDocBs->AddHtmlDoc(DocNm, CatNmV, DocStr, SaveDocP);
// train & test data
if ((DocTok->GetArgVal("LEWISSPLIT")=="TRAIN")&&(DocTok->GetArgVal("TOPICS")=="YES")){
BowDocBs->AddTrainDId(DId);}
if ((DocTok->GetArgVal("LEWISSPLIT")=="TEST")&&(DocTok->GetArgVal("TOPICS")=="YES")){
BowDocBs->AddTestDId(DId);}
}
if ((MxDocs!=-1)&&(Docs>=MxDocs)){break;}
}
// return results
BowDocBs->AssertOk();
return BowDocBs;
}
示例11: GetFNmV
void TFFile::GetFNmV(
const TStr& FPath, const TStrV& FExtV, const bool& RecurseP, TStrV& FNmV){
// prepare file-directory traversal
TStrV FPathV; FPathV.Add(FPath);
TFFile FFile(FPathV, FExtV, "", RecurseP); TStr FNm;
// traverse directory
FNmV.Clr();
while (FFile.Next(FNm)){
FNmV.Add(FNm);
}
}
示例12: GetVarNmV
void TEnv::GetVarNmV(TStrV& VarNmV) {
VarNmV.Clr();
int VarN=0;
while (_environ[VarN]!=NULL) {
TStr VarNmVal=_environ[VarN++];
TStr VarNm;
TStr VarVal;
VarNmVal.SplitOnCh(VarNm, '=', VarVal);
VarNmV.Add(VarNm);
}
}
示例13: Update
void TFtrGenBs::Update(const TStrV& FtrValV) {
EAssert(State == fgsUpdate);
EAssert(FtrValV.Len() == FtrGenV.Len());
try {
for (int FtrValN = 0; FtrValN < FtrValV.Len(); FtrValN++) {
FtrGenV[FtrValN]->Update(FtrValV[FtrValN]);
}
} catch (PExcept Ex) {
TExcept::Throw(TStr::Fmt("Error feature generation: '%s'!", Ex->GetMsgStr().CStr()));
}
}
示例14: Add
void TFtrGenSparseNumeric::Add(const TStr& Str, TIntFltKdV& SpV, int& Offset) const {
TStrV EltV; Str.SplitOnAllCh(';', EltV); TIntH UsedIdH;
for (int EltN = 0; EltN < EltV.Len(); EltN++) {
int Id; TStr Val; Split(EltV[EltN], Id, Val);
EAssertR(!UsedIdH.IsKey(Id), "Field ID repeated in '" + Str + "'!");
int TmpOffset = Offset + Id;
FtrGen->Add(Val, SpV, TmpOffset);
UsedIdH.AddKey(Id);
}
Offset += GetVals();
}
示例15: EAssert
// copy files for a particular folder info
void TBackupProfile::CopyFolder(const TStr& BaseTargetFolder, const TStr& SourceFolder, const TStrV& Extensions, const TStrV& SkipIfContainingV, const bool& IncludeSubfolders, const bool& ReportP, TStr& ErrMsg)
{
try {
// get the name of the source folder
TStrV PathV; TDir::SplitPath(SourceFolder, PathV);
EAssert(PathV.Len() > 0);
// create the folder in the base target folder
TStr TargetFolder = BaseTargetFolder + PathV[PathV.Len() - 1] + "/";
if (!TDir::Exists(TargetFolder))
TDir::GenDir(TargetFolder);
// find files to be copied
TStrV FileV;
TFFile::GetFNmV(SourceFolder, Extensions, false, FileV);
TStrV FolderV;
// copy them
for (int N = 0; N < FileV.Len(); N++) {
// we found a file
if (TFile::Exists(FileV[N])) {
const TStr FileName = TDir::GetFileName(FileV[N]);
// is this a file that we wish to ignore?
bool ShouldCopy = true;
for (int S = 0; S < SkipIfContainingV.Len(); S++) {
if (FileName.SearchStr(SkipIfContainingV[S]) >= 0)
ShouldCopy = false;
}
if (!ShouldCopy)
continue;
const TStr TargetFNm = TargetFolder + FileName;
if (ReportP)
TNotify::StdNotify->OnStatusFmt("Copying file: %s\r", FileName.CStr());
TFile::Copy(FileV[N], TargetFNm);
}
// we found a folder
else {
FolderV.Add(FileV[N]);
}
}
if (IncludeSubfolders) {
for (int N = 0; N < FolderV.Len(); N++)
CopyFolder(TargetFolder, FolderV[N], Extensions, SkipIfContainingV, IncludeSubfolders, ReportP, ErrMsg);
}
}
catch (PExcept E) {
if (ErrMsg != "")
ErrMsg += "\n";
ErrMsg += "Exception while copying from " + SourceFolder + ": " + E->GetMsgStr();
}
catch (...) {
if (ErrMsg != "")
ErrMsg += "\n";
ErrMsg += "Exception while copying from " + SourceFolder + ": " + "Unrecognized exception occured.";
}
}