diff --git a/isspam b/isspam index 37029aa..4e85c07 100755 Binary files a/isspam and b/isspam differ diff --git a/retoor_c/isspam.c b/retoor_c/isspam.c index f91d387..2907e89 100644 --- a/retoor_c/isspam.c +++ b/retoor_c/isspam.c @@ -174,22 +174,14 @@ bool is_fully_capitalized_word(char *word) { return true; } -sl *get_capitalized_words(char *content) { +sl *get_capitalized_words(sl *all_words) { sl *capitalized_words = sln(); - sl *sentences = get_sentences(content); - for (uint j = 0; j < sentences->count; j++) { - char *sentence = sentences->strings[j]; - sl *all_words = get_words(sentence); - - // Always skip the first word since sentences start with for (uint i = 0; i < all_words->count; i++) { if (is_fully_capitalized_word(all_words->strings[i])) { rstring_list_add(capitalized_words, all_words->strings[i]); } } - slf(all_words); - } - slf(sentences); + return capitalized_words; } @@ -251,16 +243,13 @@ bool containswordi(sl *words, char *word) { return false; } -sl *get_forbidden_words(char *content) { - sl *words = get_words(content); +sl *get_forbidden_words(sl *words) { sl *found = sln(); for (int j = 0; forbidden_words[j] != NULL; j++) { if (containswordi(words, forbidden_words[j])) { rstring_list_add(found, forbidden_words[j]); } } - - slf(words); return found; } unsigned int total = 0; @@ -278,8 +267,18 @@ void analyze(FILE *f) { free(clean_data); + sl *words = get_words(data); + + // All words + printf("Words: %llu\n", words->count); + if(show_words) + sld(words); + sbuf = slds(words); + stra(all, sbuf); + free(sbuf); + // All capitalized words - sl *capitalized_words = get_capitalized_words(data); + sl *capitalized_words = get_capitalized_words(words); ulonglong capitalized_words_count = capitalized_words->count; printf("Capitalized words: %llu\n", capitalized_words_count); if(show_capitalized) @@ -298,15 +297,7 @@ void analyze(FILE *f) { stra(all, sbuf); free(sbuf); - sl *words = get_words(data); - - // All words - printf("Words: %llu\n", words->count); - if(show_words) - sld(words); - sbuf = slds(words); - stra(all, sbuf); - free(sbuf); + // Numbers sl *numbers = get_numbers(data); @@ -318,7 +309,7 @@ void analyze(FILE *f) { free(sbuf); // Forbidden words - sl *fw = get_forbidden_words(data); + sl *fw = get_forbidden_words(words); printf("Forbidden words: %llu\n", fw->count); if(show_forbidden_words) sld(fw);