本文整理汇总了C++中PJsonVal::GetObjNum方法的典型用法代码示例。如果您正苦于以下问题:C++ PJsonVal::GetObjNum方法的具体用法?C++ PJsonVal::GetObjNum怎么用?C++ PJsonVal::GetObjNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PJsonVal
的用法示例。
在下文中一共展示了PJsonVal::GetObjNum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: New
TEmaSpVec::TEmaSpVec(const PJsonVal& ParamVal) : LastVal(), InitP(false) {
// type
TStr TypeStr = ParamVal->GetObjStr("emaType");
if (TypeStr == "previous") {
Type = etPreviousPoint;
} else if (TypeStr == "linear") {
Type = etLinear;
} else if (TypeStr == "next") {
Type = etNextPoint;
} else {
throw TExcept::New("Unknown ema type " + TypeStr);
}
// rest
TmInterval = ParamVal->GetObjNum("interval");
Cutoff = ParamVal->GetObjNum("cutoff", 0.0001);
InitMinMSecs = ParamVal->GetObjInt("initWindow", 0);
}
示例2:
TOnlineHistogram::TOnlineHistogram(const PJsonVal& ParamVal) {
EAssertR(ParamVal->IsObjKey("lowerBound"), "TOnlineHistogram: lowerBound key missing!");
EAssertR(ParamVal->IsObjKey("upperBound"), "TOnlineHistogram: upperBound key missing!");
// bounded lowest point
TFlt LBound = ParamVal->GetObjNum("lowerBound");
// bounded highest point
TFlt UBound = ParamVal->GetObjNum("upperBound");
EAssertR(LBound < UBound, "TOnlineHistogram: Lower bound should be smaller than upper bound");
// number of equal bins ? (not counting possibly infinite ones)
TInt Bins = ParamVal->GetObjInt("bins", 5);
EAssertR(Bins > 0, "TOnlineHistogram: Number of bins should be greater than 0");
// include infinities in the bounds?
TBool AddNegInf = ParamVal->GetObjBool("addNegInf", false);
TBool AddPosInf = ParamVal->GetObjBool("addPosInf", false);
MinCount = ParamVal->GetObjInt("initMinCount", 0);
Init(LBound, UBound, Bins, AddNegInf, AddPosInf);
};
示例3: File
TQmParam(const TStr& FNm) {
EAssertR(TFile::Exists(FNm), "Missing configuration file " + FNm);
// load configuration file
PJsonVal ConfigVal = TJsonVal::GetValFromSIn(TFIn::New(FNm));
EAssertR(ConfigVal->IsObj(), "Invalid setting file - not valid JSON");
// parse out common stuff
RootFPath = TStr::GetNrFPath(ConfigVal->GetObjStr("directory", TDir::GetCurDir()));
LockFNm = RootFPath + "./lock";
DbFPath = ConfigVal->GetObjStr("database", "./db/");
PortN = TFlt::Round(ConfigVal->GetObjNum("port"));
// parse out unicode definition file
TStr UnicodeFNm = ConfigVal->GetObjStr("unicode", TQm::TEnv::QMinerFPath + "./UnicodeDef.Bin");
if (!TUnicodeDef::IsDef()) { TUnicodeDef::Load(UnicodeFNm); }
// parse cache
if (ConfigVal->IsObjKey("cache")) {
PJsonVal CacheVal = ConfigVal->GetObjKey("cache");
// parse out index and default store cache sizes
IndexCacheSize = int64(CacheVal->GetObjNum("index", 1024)) * int64(TInt::Mega);
DefStoreCacheSize = int64(CacheVal->GetObjNum("store", 1024)) * int64(TInt::Mega);
// prase out store specific sizes, when available
if (CacheVal->IsObjKey("stores")) {
PJsonVal StoreCacheVals = CacheVal->GetObjKey("stores");
for (int StoreN = 0; StoreN < StoreCacheVals->GetArrVals(); StoreN++) {
PJsonVal StoreCacheVal = StoreCacheVals->GetArrVal(StoreN);
TStr StoreName = StoreCacheVal->GetObjStr("name");
uint64 StoreCacheSize = int64(StoreCacheVal->GetObjNum("size")) * int64(TInt::Mega);
StoreNmCacheSizeH.AddDat(StoreName, StoreCacheSize);
}
}
} else {
// default sizes are set to 1GB for index and stores
IndexCacheSize = int64(1024) * int64(TInt::Mega);
DefStoreCacheSize = int64(1024) * int64(TInt::Mega);
}
// load scripts
if (ConfigVal->IsObjKey("script")) {
// we have configuration file, read it
PJsonVal JsVals = ConfigVal->GetObjKey("script");
if (JsVals->IsArr()) {
for (int JsValN = 0; JsValN < JsVals->GetArrVals(); JsValN++) {
JsParamV.Add(TJsParam(RootFPath, JsVals->GetArrVal(JsValN)));
}
} else {
JsParamV.Add(TJsParam(RootFPath, JsVals));
}
} else {
// no settings for scripts, assume default setting
TStr SrcFPath = TStr::GetNrAbsFPath("src", RootFPath);
TFFile File(SrcFPath, ".js", false); TStr SrcFNm;
while (File.Next(SrcFNm)) {
JsParamV.Add(TJsParam(RootFPath, SrcFNm));
}
}
// load serving folders
//TODO: Add to qm config ability to edit this
if (ConfigVal->IsObjKey("wwwroot")) {
PJsonVal WwwVals = ConfigVal->GetObjKey("wwwroot");
if (WwwVals->IsArr()) {
for (int WwwValN = 0; WwwValN < WwwVals->GetArrVals(); WwwValN++) {
AddWwwRoot(WwwVals->GetArrVal(WwwValN));
}
} else {
AddWwwRoot(WwwVals);
}
}
// check for folder with admin GUI
TStr GuiFPath = TStr::GetNrAbsFPath("gui", TQm::TEnv::QMinerFPath);
if (TDir::Exists(GuiFPath)) {
WwwRootV.Add(TStrPr("admin", GuiFPath));
}
// check for any default wwwroot
TStr DefaultWwwRootFPath = TStr::GetNrAbsFPath("www", RootFPath);
if (TDir::Exists(DefaultWwwRootFPath)) {
WwwRootV.Add(TStrPr("www", DefaultWwwRootFPath));
}
}
示例4: PJsonVal
PJsonVal TDecisionTree::TNode::ExplainLabel(const int& Label) const {
if (IsLeaf()) {
if (ClassHist[Label] <= ClassHist[1 - Label]) {
return PJsonVal();
} else {
const double Prob = ClassHist[Label];
PJsonVal Result = TJsonVal::NewArr();
PJsonVal IntersectJson = TJsonVal::NewObj();
IntersectJson->AddToObj("covered", int(NExamples*Prob));
IntersectJson->AddToObj("purity", Prob);
IntersectJson->AddToObj("terms", TJsonVal::NewArr());
Result->AddToArr(IntersectJson);
return Result;
}
}
PJsonVal Result = TJsonVal::NewArr();
if (HasLeft()) {
PJsonVal LeftUnion = Left->ExplainLabel(Label);
if (!LeftUnion.Empty()) {
if (LeftUnion->GetArrVals() == 0) {
LeftUnion->AddToArr(TJsonVal::NewArr());
}
for (int i = 0; i < LeftUnion->GetArrVals(); i++) {
PJsonVal IntersectJson = LeftUnion->GetArrVal(i);
PJsonVal TermsJson = IntersectJson->GetObjKey("terms");
bool HadFtr = false;
for (int TermN = 0; TermN < TermsJson->GetArrVals(); TermN++) {
PJsonVal TermJson = TermsJson->GetArrVal(TermN);
const int TermFtrN = TermJson->GetObjInt("ftrId");
if (TermFtrN == CutFtrN) {
HadFtr = true;
if (TermJson->GetObjNum("le") == TFlt::PInf) {
TermJson->AddToObj("le", CutFtrVal);
}
}
}
if (!HadFtr) {
PJsonVal TermJson = TJsonVal::NewObj();
TermJson->AddToObj("ftrId", CutFtrN);
TermJson->AddToObj("le", CutFtrVal);
TermJson->AddToObj("gt", TFlt::NInf);
TermsJson->AddToArr(TermJson);
}
Result->AddToArr(IntersectJson);
}
}
}
if (HasRight()) {
PJsonVal RightUnion = Right->ExplainLabel(Label);
if (!RightUnion.Empty()) {
if (RightUnion->GetArrVals() == 0) {
RightUnion->AddToArr(TJsonVal::NewArr());
}
for (int i = 0; i < RightUnion->GetArrVals(); i++) {
PJsonVal IntersectJson = RightUnion->GetArrVal(i);
PJsonVal TermsJson = IntersectJson->GetObjKey("terms");
bool HadFtr = false;
for (int TermN = 0; TermN < TermsJson->GetArrVals(); TermN++) {
PJsonVal TermJson = TermsJson->GetArrVal(TermN);
const int TermFtrN = TermJson->GetObjInt("ftrId");
if (TermFtrN == CutFtrN) {
HadFtr = true;
if (TermJson->GetObjNum("gt") == TFlt::NInf) {
TermJson->AddToObj("gt", CutFtrVal);
}
}
}
if (!HadFtr) {
PJsonVal TermJson = TJsonVal::NewObj();
TermJson->AddToObj("ftrId", CutFtrN);
TermJson->AddToObj("le", TFlt::PInf);
TermJson->AddToObj("gt", CutFtrVal);
TermsJson->AddToArr(TermJson);
}
Result->AddToArr(IntersectJson);
}
}
}
return Result->GetArrVals() > 0 ? Result : PJsonVal();
}