diff --git a/isspam b/isspam index 8c32a25..37029aa 100755 Binary files a/isspam and b/isspam differ 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)