TFOut::TFOut(const TStr& FNm, const bool& Append, bool& OpenedP): TSBase(FNm.CStr()), TSOut(FNm), FileId(NULL), Bf(NULL), BfL(0){ if (FNm.GetUc()=="CON"){ FileId=stdout; } else { if (Append){FileId=fopen(FNm.CStr(), "a+b");} else {FileId=fopen(FNm.CStr(), "w+b");} OpenedP=(FileId!=NULL); if (OpenedP){ Bf=new char[MxBfL]; BfL=0;} } }
bool TSwSet::IsIn(const TStr& WordStr, const bool& UcWordStrP) const { if (WordStr.Len()<MnWordLen){ return true; } else { if (UcWordStrP){ return SwStrH.IsKey(WordStr); } else { TStr UcWordStr=WordStr.GetUc(); return SwStrH.IsKey(UcWordStr); } } }
TFAccess TFRnd::GetFAccessFromStr(const TStr& Str){ TStr UcStr=Str.GetUc(); if (UcStr=="CREATE"){return faCreate;} if (UcStr=="UPDATE"){return faUpdate;} if (UcStr=="APPEND"){return faAppend;} if (UcStr=="READONLY"){return faRdOnly;} if (UcStr=="RESTORE"){return faRestore;} if (UcStr=="NEW"){return faCreate;} if (UcStr=="CONT"){return faUpdate;} if (UcStr=="CONTINUE"){return faUpdate;} if (UcStr=="REST"){return faRestore;} if (UcStr=="RESTORE"){return faRestore;} return faUndef; }
void TGStat::Plot(const TGStatDistr& Distr, const TStr& FNmPref, TStr Desc, bool PowerFit) const { if (Desc.Empty()) Desc = FNmPref.GetUc(); if (! HasDistr(Distr) || Distr==gsdUndef || Distr==gsdMx) { return; } TPlotInfo Info = GetPlotInfo(Distr); TGnuPlot GnuPlot(Info.Val1+TStr(".")+FNmPref, TStr::Fmt("%s. G(%d, %d)", Desc.CStr(), GetNodes(),GetEdges())); GnuPlot.SetXYLabel(Info.Val2, Info.Val3); GnuPlot.SetScale(Info.Val4); const int plotId = GnuPlot.AddPlot(GetDistr(Distr), gpwLinesPoints, ""); if (PowerFit) { GnuPlot.AddPwrFit(plotId, gpwLines); } #ifdef GLib_MACOSX GnuPlot.SaveEps(); #else GnuPlot.SavePng(); #endif }
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); } }
TStr TCordisEuPart::GetNrOrgNm(const TStr& Str){ TStrV NrStrV; TChA ChA; PSwSet SwSet=TSwSet::GetSwSet(swstEnglish523); PSIn HtmlSIn=TStrIn::New(Str); THtmlLx Lx(HtmlSIn); while (Lx.Sym!=hsyEof){ if ((Lx.Sym==hsyStr)||(Lx.Sym==hsyNum)){ Lx.UcChA.ChangeCh('Â', 'A'); Lx.UcChA.ChangeCh('Á', 'A'); Lx.UcChA.ChangeCh('Ä', 'A'); Lx.UcChA.ChangeCh('Ã', 'A'); Lx.UcChA.ChangeCh('À', 'A'); Lx.UcChA.ChangeCh('Ç', 'C'); Lx.UcChA.ChangeCh('É', 'E'); Lx.UcChA.ChangeCh('È', 'E'); Lx.UcChA.ChangeCh('Ê', 'E'); Lx.UcChA.ChangeCh('Í', 'I'); Lx.UcChA.ChangeCh('Ó', 'O'); Lx.UcChA.ChangeCh('Ö', 'O'); Lx.UcChA.ChangeCh('Ñ', 'N'); Lx.UcChA.ChangeCh('Ü', 'U'); Lx.UcChA.ChangeCh('Ú', 'U'); TStr NrStr=THtmlLx::GetAsciiStr(Lx.UcChA); if ((NrStr.Len()==1)||(SwSet->IsIn(NrStr))|| (NrStr=="AG")||(NrStr=="GMBH")||(NrStr=="LTD")||(NrStr=="SRL")|| (NrStr=="SA")||(NrStr=="EV")||(NrStr=="AS")||(NrStr=="AB")|| (NrStr=="NV")||(NrStr=="BV")|| (NrStr=="AKTIENGESELLSCHAFT")||(NrStr=="LIMITED")|| (NrStr=="FUER")||(NrStr=="FUR")){ NrStr="";} if (!NrStr.Empty()){NrStrV.Add(NrStr);} } Lx.GetSym(); } TChA NrChA; for (int NrStrN=0; NrStrN<NrStrV.Len(); NrStrN++){ if (NrStrN>0){NrChA+=' ';} NrChA+=NrStrV[NrStrN]; } if (NrChA.Empty()){ NrChA=Str.GetUc(); } return NrChA; }
///////////////////////////////////////////////// // Stemmer TStr TStemmer::GetStem(const TStr& WordStr, const bool& ToUcP) { TStr UCWordStr; if (ToUcP) { // convert to upper-case UCWordStr = WordStr.GetUc(); } else { // not convert to upper-case UCWordStr = WordStr; } // check for synonyms TStr SynomymStr; if (SynonymStrToWordStr.IsKeyGetDat(UCWordStr, SynomymStr)) { UCWordStr=SynomymStr; } // get stem TStemmerType _StemmerType=TStemmerType(int(StemmerType)); TStr StemStr; if (_StemmerType==stmtPorter) { StemStr=TPorterStemmer::StemX(UCWordStr); } else { return UCWordStr; } // get real word from stem if (bool(RealWordP)) { TStr RealWordStr; if (StemStrToRealWordStrH.IsKeyGetDat(StemStr, RealWordStr)) { StemStr=RealWordStr; } else { StemStrToRealWordStrH.AddDat(StemStr, UCWordStr); StemStr=UCWordStr; } } // return stem return StemStr; }
void TGStatVec::ImposeDistr(const TGStatDistr& Distr, const TStr& FNmPref, TStr Desc, const bool& ExpBin, const bool& PowerFit, const TGpSeriesTy& PlotWith, const TStr& Style) const { if (Desc.Empty()) Desc = FNmPref.GetUc(); if (! At(0)->HasDistr(Distr) || Distr==gsdUndef || Distr==gsdMx) { return; } TGStat::TPlotInfo Info = At(0)->GetPlotInfo(Distr); TGnuPlot GnuPlot(Info.Val1+TStr(".")+FNmPref, TStr::Fmt("%s. G(%d, %d) --> G(%d, %d)", Desc.CStr(), At(0)->GetNodes(), At(0)->GetEdges(), Last()->GetNodes(), Last()->GetEdges())); GnuPlot.SetXYLabel(Info.Val2, Info.Val3); GnuPlot.SetScale(Info.Val4); int plotId; for (int at = 0; at < Len(); at++) { TStr Legend = At(at)->GetNm(); if (Legend.Empty()) { Legend = At(at)->GetTmStr(); } if (! ExpBin) { plotId = GnuPlot.AddPlot(At(at)->GetDistr(Distr), PlotWith, Legend, Style); } else { TFltPrV ExpBinV; TGnuPlot::MakeExpBins(At(at)->GetDistr(Distr), ExpBinV, 2, 0); plotId = GnuPlot.AddPlot(ExpBinV, PlotWith, Legend, Style); } if (PowerFit) { GnuPlot.AddPwrFit(plotId, gpwLines); } } GnuPlot.SavePng(); }
void TExpBi::AddBi(const TStr& ExpBiNm, const TExpBiId& ExpBiId, const TExpBiArgType& ExpBiArgType){ ExpBiNmToIdH.AddDat(ExpBiNm.GetUc(), TInt(int(ExpBiId))); ExpBiIdToArgTypeH.AddDat(TInt(int(ExpBiId)), TInt(int(ExpBiArgType))); }
bool THttp::IsGifFExt(const TStr& FExt){ return (FExt.GetUc()==TFile::GifFExt.GetUc()); }
// file extensions bool THttp::IsHtmlFExt(const TStr& FExt){ TStr UcFExt=FExt.GetUc(); return ((UcFExt==TFile::HtmlFExt.GetUc())||(UcFExt==TFile::HtmFExt.GetUc())); }
void TStrParser::DocStrToSylIdV(const TStr& _DocStr, TIntV& SyllablesIdV) { TStr DocStr = _DocStr.GetUc(); // to upper case Fail; }
TEST(TStr, EqI) { TStr Mixedcase = "AbCd"; TStr Empty = ""; EXPECT_TRUE(Mixedcase.EqI(Mixedcase.GetUc())); EXPECT_TRUE(Empty.EqI(Empty)); }