本文整理汇总了C++中TStr::SplitOnAllCh方法的典型用法代码示例。如果您正苦于以下问题:C++ TStr::SplitOnAllCh方法的具体用法?C++ TStr::SplitOnAllCh怎么用?C++ TStr::SplitOnAllCh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStr
的用法示例。
在下文中一共展示了TStr::SplitOnAllCh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadAcXml
PAlignPair TAlignPair::LoadAcXml(const TStr& FNm, const int& MxSents) {
printf("Loading %s ...\n", FNm.CStr());
// get the lanugagne names
TStr BaseNm = FNm.GetFMid();
TStrV PartV; BaseNm.SplitOnAllCh('-', PartV);
IAssertR(PartV.Len() == 3, "Bad file name: " + BaseNm);
// prepare aligne pair
PAlignPair AlignPair = TAlignPair::New(PartV[1], PartV[2]);
// parse the XML
PTransCorpus TransCorpus = TTransCorpus::LoadAC(FNm, MxSents * 4);
// select subset of sentences which will go into aligned corpus
const int AllSents = TransCorpus->GetSentences();
TIntV SentIdV(AllSents, 0);
for (int SentId = 0; SentId < AllSents; SentId++) {
SentIdV.Add(SentId);
}
if (MxSents != -1 && AllSents > MxSents) {
TRnd Rnd(1);
SentIdV.Shuffle(Rnd);
SentIdV.Trunc(MxSents);
}
// add the sentences to the bow
const int Sents = SentIdV.Len();
for (int SentIdN = 0; SentIdN < Sents; SentIdN++) {
const int SentId = SentIdV[SentIdN];
const TStr& Sent1 = TransCorpus->GetOrgStr(SentId);
const TStr& Sent2 = TransCorpus->GetRefTransStrV(SentId)[0];
AlignPair->AddSent(Sent1, Sent2);
}
// finish the alignment pair
AlignPair->Def();
return AlignPair;
}
示例2: GetAuthNmVPubStr
void TGgSchRef::GetAuthNmVPubStr(
const TStr& AuthNmVPubStr, TStrV& AuthNmV, TStr& PubNm, TStr& PubYearStr){
// split input string into two parts
TStr AuthNmVStr; TStr PubStr;
AuthNmVPubStr.SplitOnStr(AuthNmVStr, " - ", PubStr);
// author-names string
AuthNmVStr.SplitOnAllCh(',', AuthNmV, true);
for (int AuthN=0; AuthN<AuthNmV.Len(); AuthN++){
AuthNmV[AuthN].ToTrunc();
}
if ((!AuthNmV.Empty())&&
((AuthNmV.Last().IsStrIn("..."))||(AuthNmV.Last().Len()<=2))){
AuthNmV.DelLast();
}
// publication-name & publication-year string
TStr OriginStr; TStr LinkStr;
PubStr.SplitOnStr(OriginStr, " - ", LinkStr);
OriginStr.SplitOnLastCh(PubNm, ',', PubYearStr);
PubNm.ToTrunc(); PubYearStr.ToTrunc();
if ((PubYearStr.Len()>=4)&&(PubYearStr.GetSubStr(0, 3).IsInt())){
PubYearStr=PubYearStr.GetSubStr(0, 3);
} else
if ((PubNm.Len()>=4)&&(PubNm.GetSubStr(0, 3).IsInt())){
PubYearStr=PubNm.GetSubStr(0, 3); PubNm="";
} else {
PubYearStr="";
}
}
示例3: LoadVoc
PLwOnto TLwOnto::LoadVoc(const TStr& FNm) {
// create ontology
PLwOnto LwOnto = TLwOnto::New();
// create language object
int EnLangId = LwOnto->GetLangBs()->AddLang("EN", "English");
// create term-types
PLwTermType TermType = TLwTermType::New(0, "Term", EnLangId);
LwOnto->GetTermTypeBs()->AddTermType(TermType);
// create terms
{printf("Creating terms ...\n");
// load terms from file
TStr VocFileStr = TStr::LoadTxt(FNm);
VocFileStr.DelChAll('\r');
TStrV TermNmV; VocFileStr.SplitOnAllCh('\n', TermNmV);
// add terms to base
const int Terms = TermNmV.Len();
for (int TermId = 0; TermId<Terms; TermId++){
if (TermId%1000==0){printf("%d/%d\r", TermId, Terms);}
TStr TermNm = TermNmV[TermId];
// create term
PLwTerm Term=TLwTerm::New(TermId, TermNm, EnLangId, TermType->GetTermTypeId());
LwOnto->GetTermBs()->AddTerm(Term);
}
printf("Done. (%d)\n", LwOnto->GetTermBs()->GetTerms());}
// return ontology
return LwOnto;
}
示例4: GetCanonicalPath
TStr TNodeJsFPath::GetCanonicalPath(const TStr& FPath) {
// Get absolute path
TStr AbsFPath = TStr::GetNrAbsFPath(FPath);
// Remove any redundancies
TStrV CanonV; AbsFPath.SplitOnAllCh('/', CanonV);
TSStack<TStr> CanonS; TStr CurrStr;
for (int ElN = 0; ElN < CanonV.Len(); ++ElN) {
CurrStr = CanonV.GetVal(ElN);
if (CurrStr == "..") {
EAssertR(!CanonS.Empty(), "Stack empty");
CanonS.Pop();
} else if (CurrStr != ".") {
CanonS.Push(CurrStr+"/");
}
}
// Assemble the canonical path (from left to right
EAssertR(!CanonS.Empty(), "Stack empty");
// We start with drive letter (Windows) or slash (Unix)
TChA CanonFPath = AbsFPath.LeftOf('/'); CanonFPath += '/';
// Get the rest of the path
for (int CanonN = CanonS.Len() - 1; CanonN >= 0; CanonN--) {
CanonFPath += CanonS[CanonN];
}
// Done
return CanonFPath;
}
示例5: GetCountryNm
/////////////////////////////////////////////////
// Geographical-IP
void TGeoIpBs::GetCountryNm(const TStr& IpNumStr, TStr& CountrySNm, TStr& CountryLNm){
// prepare country-names
CountrySNm="--"; CountryLNm="Unknown";
// split ip-num to sub-number-strings
TStrV IpSubNumStrV; IpNumStr.SplitOnAllCh('.', IpSubNumStrV, false);
// convert sub-number-strings to sub-numbers and ip-number
int IpSubNum0, IpSubNum1, IpSubNum2, IpSubNum3;
uint IpNum;
if (
IpSubNumStrV[0].IsInt(true, 0, 255, IpSubNum0)&&
IpSubNumStrV[1].IsInt(true, 0, 255, IpSubNum1)&&
IpSubNumStrV[2].IsInt(true, 0, 255, IpSubNum2)&&
IpSubNumStrV[3].IsInt(true, 0, 255, IpSubNum3)){
IpNum=16777216*IpSubNum0+65536*IpSubNum1+256*IpSubNum2+IpSubNum3;
} else {
return;
}
// get country-id from ip-number
int CountryId=-1;
int IpNumN; CountryMnIpNumV.SearchBin(IpNum+1, IpNumN);
if (IpNumN>0){
uint MnIpNum=CountryMnIpNumV[IpNumN-1];
uint MxIpNum=MnIpNumToMxIpNumCountryIdPrH.GetDat(MnIpNum).Val1;
if ((MnIpNum<=IpNum)&&(IpNum<=MxIpNum)){
CountryId=MnIpNumToMxIpNumCountryIdPrH.GetDat(MnIpNum).Val2;
}
}
// get country-names
if (CountryId!=-1){
CountrySNm=CountrySNmToLNmH.GetKey(CountryId);
CountryLNm=CountrySNmToLNmH[CountryId];
}
}
示例6: Update
void TFtrGenSparseNumeric::Update(const TStr& Str) {
TStrV EltV; Str.SplitOnAllCh(';', EltV);
for (int EltN = 0; EltN < EltV.Len(); EltN++) {
int Id; TStr Val; Split(EltV[EltN], Id, Val);
MxId = TInt::GetMx(Id, MxId);
FtrGen->Update(Val);
}
}
示例7: Add
void TFtrGenMultiNom::Add(const TStr& Str, TIntFltKdV& SpV, int& Offset) const {
TStrV EltV; Str.SplitOnAllCh(';', EltV);
for (int EltN = 0; EltN < EltV.Len(); EltN++) {
int TmpOffset = Offset;
FtrGen->Add(EltV[EltN], SpV, TmpOffset);
}
Offset += GetVals();
}
示例8: GetValV
void TFtrGenMultiNom::GetValV(const TStr& Str, TStrV& ValV) const {
TStrV EltV; Str.SplitOnAllCh(';', EltV); ValV.Clr();
for (int EltN = 0; EltN < EltV.Len(); EltN++) {
const TStr& Val = EltV[EltN];
TStrV SubValV; FtrGen->GetValV(Val, SubValV);
ValV.AddV(SubValV);
}
}
示例9: ArgV
TEnv::TEnv(const TStr& _ArgStr, const PNotify& _Notify)
: ArgV(),
HdStr(),
MnArgs(1),
SilentP(false),
Notify(_Notify) {
_ArgStr.SplitOnAllCh(' ', ArgV);
}
示例10: 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); }
}
}
示例11: LoadCascadesTxt
void TNetInfBs::LoadCascadesTxt(TSIn& SIn, const int& Model, const double& alpha) {
TStr Line;
SIn.GetNextLn(Line);
while (!SIn.Eof() && Line != "") {
TStrV NIdV; Line.SplitOnAllCh(',', NIdV);
AddNodeNm(NIdV[0].GetInt(), TNodeInfo(NIdV[1], 0)); SIn.GetNextLn(Line); }
printf("All nodes read!\n");
while (!SIn.Eof()) { SIn.GetNextLn(Line); AddCasc(Line, Model, alpha); }
printf("All cascades read!\n");
}
示例12: LoadGroundTruthTxt
void TNetInfBs::LoadGroundTruthTxt(TSIn& SIn) {
GroundTruth = TNGraph::New(); TStr Line;
// add nodes
SIn.GetNextLn(Line);
while (!SIn.Eof() && Line != "") {
TStrV NIdV; Line.SplitOnAllCh(',', NIdV);
GroundTruth->AddNode(NIdV[0].GetInt()); SIn.GetNextLn(Line); }
// add edges
while (!SIn.Eof()) {
SIn.GetNextLn(Line);
TStrV NIdV; Line.SplitOnAllCh(',', NIdV);
GroundTruth->AddEdge(NIdV[0].GetInt(), NIdV[1].GetInt());
Alphas.AddDat(TIntPr(NIdV[0].GetInt(), NIdV[1].GetInt())) = NIdV[2].GetFlt();
}
printf("groundtruth nodes:%d edges:%d\n", GroundTruth->GetNodes(), GroundTruth->GetEdges());
}
示例13: addCascade
void TGreedyAlg::addCascade(const TStr& cascadeStr) {
TStrV NIdV;
cascadeStr.SplitOnAllCh(';', NIdV);
TCascade C;
for (int i = 0; i < NIdV.Len(); i++) {
TStr NId, Tm; NIdV[i].SplitOnCh(NId, ',', Tm);
IAssert( IsNodeNm(NId.GetInt()) );
GetNodeInfo(NId.GetInt()).Vol = GetNodeInfo(NId.GetInt()).Vol + 1;
C.Add(NId.GetInt(), Tm.GetFlt());
}
C.Sort();
cascadeV.Add(C);
}
示例14: loadCascadesFromFile
void TGreedyAlg::loadCascadesFromFile(TSIn& SIn) {
TStr line;
SIn.GetNextLn(line);
while (!SIn.Eof() && line != "") {
TStrV NIdV;
line.SplitOnAllCh(',', NIdV);
addNodeNm(NIdV[0].GetInt(), TNodeInfo(NIdV[1], 0)); SIn.GetNextLn(line);
}
printf("All nodes read!\n");
while (!SIn.Eof()) {
SIn.GetNextLn(line); addCascade(line);
}
printf("All cascades read!\n");
}
示例15: AddCasc
void TNetInfBs::AddCasc(const TStr& CascStr, const int& Model, const double& alpha) {
TStrV NIdV; CascStr.SplitOnAllCh(',', NIdV);
TCascade C(alpha, Model);
for (int i = 0; i < NIdV.Len(); i+=2) {
int NId;
double Tm;
NId = NIdV[i].GetInt();
Tm = NIdV[i+1].GetFlt();
GetNodeInfo(NId).Vol = GetNodeInfo(NId).Vol + 1;
C.Add(NId, Tm);
}
C.Sort();
CascV.Add(C);
}