From 3785af9bb473af12445644ee9820219494655548 Mon Sep 17 00:00:00 2001 From: retoor Date: Sat, 30 Nov 2024 20:32:55 +0100 Subject: [PATCH] Updated version. --- isspam | Bin 33280 -> 33312 bytes isspam.c | 13 ++++++++++++- totals.py | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 totals.py diff --git a/isspam b/isspam index 8c32a25ecc2f0fc23797d8975995fcd6454586ff..37029aad7d45889dd466433f9cc526bd57ede09c 100755 GIT binary patch delta 4926 zcmaJ_3sh9c8NRcyxFGJLLKmA+br02KbF!quuloL+mCIdJz$>~ z>={4y6-q*_QLhX3svmop+Q4=SRw|bGqpxr;Ee89EV8i^_i*y&*%Yu#bV~6O`P-}FM zD7Iujc2u@+F!Yh233E`Y&X)8{K>v1VTVkb7qqG=rvUjZ9GUq}1#Mo$ZfIdHVk~I}h zM+}Ve9J946JwK=_Jf5ZJ$7ar5T_8!Me}$^5WvwvMB<6KRA@FHxubu-_i!gotJvU8+ z$wTi8k0U|!k?-Vvd6WMZ zU`UAe-JBXT$_2m6A(E82JoDbnW%tUS?|Gj0$nLLFN@QVAtY1ZHCL^SW#cvC0uJVTRZqm1IO4aOfZeSCOJk%!z;NRX(~fp>@JIM0Lf zIL1NvIa#F4&cJv!eSI*%IXga5cDECm#2kb{_87YoC6{EkygJX`c)j|5WgHSJ@LZHz zVtUxLc@xVlv8Y>zue6R~tXMpq%F_zkeCe1Yo4Ah{D#l@fTi3XN^9}(Q6gr@A z6i)T&t(wB^0H$z73H4K0Fs!gkC_Ky+{_<}v6O$714Oh55;*KH6T%d>xBxwToK!6q9 zivupLr#^;{FQLuHkSr7;xx%7hg|6#dVc(q!4$lb;L4{9!`a6^PB)z~VNmcR&ekxEm zEN}{rM0UB2udx^9+y|PYN!j-uS6Kd2h2v0ohAZ5N=L$Coo1{xhKl^~Ne)7Q?T0=qfco>Q z%9g1X$Y!&Ow^gN_<0Ykt+1)dh1WluxBg!zbM4qng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#sV-ya$+% z@92BL9^m(^{$EWi#GG{jeL&9_2nckagfP%Iq-j~`NH4G)I0{?^w4XwPKp${FtAD9! z#~FWG)9kTGWY~kiDD)0%ng=+9Bj5ng9Y$ba7rwDsI8H1$Dw=>koU5+`o6c#P2}h-8 z6g>qF0Xu;`V@Mci{|tflC|6FgFv!ANi1!IP=$K=ZFx=eCC_E{6 zoAHj*q$;bid_dE_pkqoJbyVF%2IzxT)8v>zy0~SBs+>-n3RMM>B1#5$fLA=Ngf%edzRdlk%r;EO}IA2Cz>ko)n`qcFej_%waOgw z5-n10jr|_y@*0WeI<0h%k|(EqN{=Wx z4!Z6(zJ%{x13g!hMeAy2#-6}zj>Xbtu9-1ShIeCVeNAdY)io@?d?dPSl)hh+j?}_6 zzcJeTHO(5TSoV)Z>R#reXF;R{h}VZA9zJQ zawDLk9=QWNC+aV7#HxH%7$Se@;}82A>%WeXFW1oYwN>)y;?U}~eT1~qx$E*UY;?uC z7i5fk{Q3sjvM{uL{a!-+G-<mc1vPi?T0ZS5p_de4gjON9pE`RxBxI`I>fbwA#*!R^@Dl@$A+?`i}WH6R`i2B%74% z(aqQ*{K??Mux9`$Hx``HSvXbR=48M2Ndi*x?@*{N5Cadik(W+^d z?!Hg73eh*f9%fpyO)3{!f|TB65p2Vvt$T)U|5ngv==27wEe6LD%cskxoBt#_V57?$ ztj;{a4v4<9ZOxt{*psAm>EWo}RSN$e;V2{}Cq39;CF^KXqm?{DPeJ$3%u~iCX7W*m z$ot`wNBX(vF#FB8BD6e0iya2+vEblLrU&JePu>RJ=&;SbLbnb^W$E8 MK(9SUE4F9;AK$A%1ONa4 diff --git a/isspam.c b/isspam.c index 95b3aac..f91d387 100644 --- a/isspam.c +++ b/isspam.c @@ -263,7 +263,12 @@ sl *get_forbidden_words(char *content) { slf(words); return found; } +unsigned int total = 0; + void analyze(FILE *f) { + total = total + 1; + + printf("#%u\n", total); char *data = fread_till_eof(f); str_t *all = strn(1337); @@ -321,9 +326,15 @@ void analyze(FILE *f) { stra(all, sbuf); free(sbuf); strd(all); + if(words->count){ + double capitalized_word_percentage = 100 * ((double)capitalized_words->count / (double)words->count); + + printf("Capitalized percentage: %f%%\n",capitalized_word_percentage); + double forbidden_word_percentage = 100 * ((double)fw->count / (double)words->count); + printf("Forbidden percentage: %f%%\n",forbidden_word_percentage); ulonglong word_count_per_sentence = words->count / (sentences->count ? sentences->count : 1); printf("Word count per sentence: %llu\n", word_count_per_sentence); - + } slf(capitalized_words); slf(sentences); slf(words); diff --git a/totals.py b/totals.py new file mode 100644 index 0000000..5a7f497 --- /dev/null +++ b/totals.py @@ -0,0 +1,41 @@ +# +# [USAGE] +# +# This quick & dirty script will summarize the output +# generated by the isspam application. +# To use, you do: +# ./isspam ./your-content/*.txt > output.txt +# Then you execute: python totals.py output.txt +# - retoor + +import sys +import pathlib + +totals = {} +count = 0 +with pathlib.Path(sys.argv[1]).open("r") as f: + + data = f.read() + for line in data.split("\n"): + if line.startswith("<"): + continue + parts = line.split(": ") + if(len(parts) < 2): + continue + key = parts[0] + if key == "File": + count += 1 + if not key in ["File","Memory usage"]: + if key not in totals: + totals[key] = 0.0 + + value = float(parts[1].replace("%","")) + totals[key] += value + else: + value = parts[1] + +for key, value in totals.items(): + print(key.count("percentage")) + if key.count("percentage") > 0: + value = value / count + print(key,":",value)