void TWebTxtBsSrv::AddHitSetChA( const PTxtBsRes& TxtBsRes, const TStr& RqContTypeStr, const int& HitSetN, const int& HitSetDocs, const int& StrHitSets, const PUrlEnv& UrlEnv, TChA& OutChA){ // get hit-set data TStr PrevUrlStr; TStrPrV NmUrlStrPrV; TStr NextUrlStr; TxtBsRes->GetHitSet( HitSetN, HitSetDocs, StrHitSets, HitSetUrlFldNm, UrlEnv, PrevUrlStr, NmUrlStrPrV, NextUrlStr); // hit-set header TStr HitSetHdTpl=GetTplVal(RqContTypeStr, "HitSetHd"); OutChA+=HitSetHdTpl; // hit-set 'previous' if (!PrevUrlStr.Empty()){ TStr HitSetPrevTpl=GetTplVal(RqContTypeStr, "HitSetPrev"); HitSetPrevTpl.ChangeStrAll(UrlMacro, PrevUrlStr); OutChA+=HitSetPrevTpl; } // hit-set records for (int NmN=0; NmN<NmUrlStrPrV.Len(); NmN++){ TStr Nm=NmUrlStrPrV[NmN].Val1; TStr UrlStr=NmUrlStrPrV[NmN].Val2; if (UrlStr.Empty()){ // hit-set record with name TStr HitSetRecTpl=GetTplVal(RqContTypeStr, "HitSetRecNm"); HitSetRecTpl.ChangeStrAll(NmMacro, Nm); OutChA+=HitSetRecTpl; } else { // hit-set record with linked name TStr HitSetRecTpl=GetTplVal(RqContTypeStr, "HitSetRecLinkedNm"); HitSetRecTpl.ChangeStrAll(NmMacro, Nm); HitSetRecTpl.ChangeStrAll(UrlMacro, UrlStr); OutChA+=HitSetRecTpl; } } // hit-set 'next' if (!NextUrlStr.Empty()){ TStr HitSetNextTpl=GetTplVal(RqContTypeStr, "HitSetNext"); HitSetNextTpl.ChangeStrAll(UrlMacro, NextUrlStr); OutChA+=HitSetNextTpl; } // hit-set footer TStr HitSetFtTpl=GetTplVal(RqContTypeStr, "HitSetFt"); OutChA+=HitSetFtTpl; }
void TExp::GetBiDescV(TStrPrV& BiDescV){ BiDescV.Clr(); // constants BiDescV.Add(TStrPr("True", "Logical 'True' == 1.")); BiDescV.Add(TStrPr("False", "Logical 'False' == 0.")); BiDescV.Add(TStrPr("E", "Nat. logarithm basis (2.7182...).")); BiDescV.Add(TStrPr("Pi", "Constant pi (3.1415...).")); // trigonometric funcions BiDescV.Add(TStrPr("Sin(X)", "Sine of angle in radians.")); BiDescV.Add(TStrPr("Cos(X)", "Cosine of angle in radians.")); BiDescV.Add(TStrPr("Tan(X)", "Tangent of angle in radians.")); BiDescV.Add(TStrPr("ASin(X)", "Arc sine of (-1..+1).")); BiDescV.Add(TStrPr("ACos(X)", "Arc cosine of (-1..+1).")); BiDescV.Add(TStrPr("ATan(X)", "Arc tangent of (-inf..+inf).")); BiDescV.Add(TStrPr("SinH(X)", "Hyperbolic sine.")); BiDescV.Add(TStrPr("CosH(X)", "Hyperbolic cosine.")); BiDescV.Add(TStrPr("TanH(X)", "Hyperbolic tangent.")); // exponential functions BiDescV.Add(TStrPr("Pow(X, Y)", "X to the power of Y.")); BiDescV.Add(TStrPr("Exp(X)", "Exponential E to the power of X.")); BiDescV.Add(TStrPr("Sqr(X)", "X squared.")); BiDescV.Add(TStrPr("Sqrt(X)", "Positive square root.")); BiDescV.Add(TStrPr("Log(X)", "Natural logarithm.")); BiDescV.Add(TStrPr("Log10(X)", "Base 10 logarithm.")); // number manipulation functions BiDescV.Add(TStrPr("Ceil(X)", "The smallest integer not less than X.")); BiDescV.Add(TStrPr("Floor(X)", "The largest integer not greater than X.")); BiDescV.Add(TStrPr("Int(X)", "Integer part of X.")); BiDescV.Add(TStrPr("Frac(X)", "Fractional part of X.")); BiDescV.Add(TStrPr("Abs(X)", "Absolute value of X.")); // random deviates BiDescV.Add(TStrPr("UniDev()", "Uniform deviate (0..1).")); BiDescV.Add(TStrPr("NrmDev()", "Normal deviate (0, 1).")); BiDescV.Add(TStrPr("ExpDev()", "Exponential deviate.")); BiDescV.Add(TStrPr("GamDev(Order)", "Gamma deviate of Order.")); BiDescV.Add(TStrPr("PoiDev(Mean)", "Poisson deviate.")); BiDescV.Add(TStrPr("BinDev(Prb, Trials)", "Binomial deviate.")); // operators BiDescV.Add(TStrPr("+N", "Unary plus.")); BiDescV.Add(TStrPr("-N", "Unary minus.")); BiDescV.Add(TStrPr("!L", "Not.")); BiDescV.Add(TStrPr("N1+N2", "Plus.")); BiDescV.Add(TStrPr("N1-N2", "Minus.")); BiDescV.Add(TStrPr("N1*N2", "Multiply.")); BiDescV.Add(TStrPr("N1/N2", "Division.")); BiDescV.Add(TStrPr("N1#N2", "Integer division.")); BiDescV.Add(TStrPr("N1%N2", "Modulo.")); BiDescV.Add(TStrPr("L1&L2", "And.")); BiDescV.Add(TStrPr("L1|L2", "Or.")); BiDescV.Add(TStrPr("E1=E2", "Equal.")); BiDescV.Add(TStrPr("E1<>E2", "Not equal.")); BiDescV.Add(TStrPr("E1<E2", "Less.")); BiDescV.Add(TStrPr("E1>E2", "Greater.")); BiDescV.Add(TStrPr("E1<=E2", "Less or equal.")); BiDescV.Add(TStrPr("E1>=E2", "Greater or equal.")); BiDescV.Add(TStrPr("L?E1:E2", "If L then return E1 else return E2.")); }
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)); } }
void AddWwwRoot(const PJsonVal& WwwVal) { WwwRootV.Add(TStrPr(WwwVal->GetObjStr("name"), TStr::GetNrAbsFPath(WwwVal->GetObjStr("path"), RootFPath))); }
///////////////////////////////////////////////// // Best-Paths void GetBestPaths( const TStr& SrcNmObjStr, const TStr& DstNmObjStr, const PNmObjBs& NmObjBs){ int SrcNmObjId=NmObjBs->GetNmObjId(SrcNmObjStr); int DstNmObjId=NmObjBs->GetNmObjId(DstNmObjStr); int NmObjs=NmObjBs->GetNmObjs(); TIntPrV ParLevPrV(NmObjs); TIntPrV DstParLevPrV; ParLevPrV.PutAll(TIntPr(-1, -1)); int CurLev=0; ParLevPrV[SrcNmObjId]=TIntPr(SrcNmObjId, CurLev); forever{ CurLev++; int NewEdges=0; for (int NmObjId1=0; NmObjId1<NmObjs; NmObjId1++){ if (ParLevPrV[NmObjId1].Val2==CurLev-1){ TIntV DocIdV1; NmObjBs->GetNmObjDocIdV(NmObjId1, DocIdV1); for (int NmObjId2=0; NmObjId2<NmObjs; NmObjId2++){ if ((NmObjId2==DstNmObjId)||(ParLevPrV[NmObjId2].Val2==-1)){ TIntV DocIdV2; NmObjBs->GetNmObjDocIdV(NmObjId2, DocIdV2); TIntV IntrsDocIdV; DocIdV1.Intrs(DocIdV2, IntrsDocIdV); if (!IntrsDocIdV.Empty()){ ParLevPrV[NmObjId2]=TIntPr(NmObjId1, CurLev); NewEdges++; if (NmObjId2==DstNmObjId){ DstParLevPrV.Add(TIntPr(NmObjId1, CurLev)); } } } } } } if ((NewEdges==0)||(ParLevPrV[DstNmObjId].Val2!=-1)){ break; } } // prepare graph THash<TStr, PVrtx> VrtxNmToVrtxH; TStrPrV VrtxNmPrV; VrtxNmToVrtxH.AddKey(SrcNmObjStr); VrtxNmToVrtxH.AddKey(DstNmObjStr); // write path ContexterF->NmObjLinkageREd->Clear(); for (int DstParLevPrN=0; DstParLevPrN<DstParLevPrV.Len(); DstParLevPrN++){ ParLevPrV[DstNmObjId]=DstParLevPrV[DstParLevPrN]; int DstParLev=ParLevPrV[DstNmObjId].Val2; TStr DstNmObjStr=NmObjBs->GetNmObjStr(DstNmObjId); ContexterF->NmObjLinkageREd->Lines->Add(DstNmObjStr.CStr()); int ParNmObjId=DstNmObjId; TStr PrevNmObjStr=DstNmObjStr; forever { if (ParNmObjId==SrcNmObjId){break;} ParNmObjId=ParLevPrV[ParNmObjId].Val1; int ParLev=ParLevPrV[ParNmObjId].Val2; TStr CurNmObjStr=NmObjBs->GetNmObjStr(ParNmObjId); TStr ParNmObjStr=TStr::GetSpaceStr((DstParLev-ParLev)*4)+CurNmObjStr; ContexterF->NmObjLinkageREd->Lines->Add(ParNmObjStr.CStr()); // create vertex & edge VrtxNmToVrtxH.AddKey(CurNmObjStr); if (!PrevNmObjStr.Empty()){ if (PrevNmObjStr<CurNmObjStr){ VrtxNmPrV.AddUnique(TStrPr(PrevNmObjStr, CurNmObjStr)); } else if (PrevNmObjStr>CurNmObjStr){ VrtxNmPrV.AddUnique(TStrPr(CurNmObjStr, PrevNmObjStr)); } } // save curent named-object PrevNmObjStr=CurNmObjStr; } } // generate graph // create graph PGraph Graph=TGGraph::New(); // create vertices for (int VrtxN=0; VrtxN<VrtxNmToVrtxH.Len(); VrtxN++){ TStr VrtxNm=VrtxNmToVrtxH.GetKey(VrtxN); PVrtx Vrtx=TGVrtx::New(VrtxNm); VrtxNmToVrtxH.GetDat(VrtxNm)=Vrtx; Graph->AddVrtx(Vrtx); } // create edges for (int EdgeN=0; EdgeN<VrtxNmPrV.Len(); EdgeN++){ PVrtx Vrtx1=VrtxNmToVrtxH.GetDat(VrtxNmPrV[EdgeN].Val1); PVrtx Vrtx2=VrtxNmToVrtxH.GetDat(VrtxNmPrV[EdgeN].Val2); PEdge Edge=new TGEdge(Vrtx1, Vrtx2, TStr::Fmt("_%d", EdgeN), false); Graph->AddEdge(Edge); } // place graph ContexterF->State->ElGraph=Graph; TRnd Rnd(1); ContexterF->State->ElGraph->PlaceSimAnnXY(Rnd, ContexterF->State->ElGks); // draw graph ContexterF->State->ElGks->Clr(); ContexterF->ElPbPaint(NULL); }