This commit is contained in:
parent
94e5d7bfa5
commit
3785af9bb4
13
isspam.c
13
isspam.c
@ -263,7 +263,12 @@ sl *get_forbidden_words(char *content) {
|
|||||||
slf(words);
|
slf(words);
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
unsigned int total = 0;
|
||||||
|
|
||||||
void analyze(FILE *f) {
|
void analyze(FILE *f) {
|
||||||
|
total = total + 1;
|
||||||
|
|
||||||
|
printf("#%u\n", total);
|
||||||
char *data = fread_till_eof(f);
|
char *data = fread_till_eof(f);
|
||||||
|
|
||||||
str_t *all = strn(1337);
|
str_t *all = strn(1337);
|
||||||
@ -321,9 +326,15 @@ void analyze(FILE *f) {
|
|||||||
stra(all, sbuf);
|
stra(all, sbuf);
|
||||||
free(sbuf);
|
free(sbuf);
|
||||||
strd(all);
|
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);
|
ulonglong word_count_per_sentence = words->count / (sentences->count ? sentences->count : 1);
|
||||||
printf("Word count per sentence: %llu\n", word_count_per_sentence);
|
printf("Word count per sentence: %llu\n", word_count_per_sentence);
|
||||||
|
}
|
||||||
slf(capitalized_words);
|
slf(capitalized_words);
|
||||||
slf(sentences);
|
slf(sentences);
|
||||||
slf(words);
|
slf(words);
|
||||||
|
41
totals.py
Normal file
41
totals.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user