if a word has forbidden only count it once. uses for loops again whoops

This commit is contained in:
JestDotty
2025-03-23 23:23:40 -04:00
parent 320f6bf4af
commit 55a4901a30
2 changed files with 36 additions and 2 deletions
+5 -2
View File
@@ -58,8 +58,8 @@ impl Stats {
return;
};
self.file_count += 1;
self.muncher(&text);
// self.for_loops(&text);
// self.muncher(&text);
self.for_loops(&text);
}
#[allow(dead_code)]
/// probably buggy. for example, are new lines sentences? what if the text has no last period?
@@ -89,6 +89,7 @@ impl Stats {
for forbidden_word in FORBIDDEN_WORDS {
if lowercase_word.contains(forbidden_word) {
self.forbidden_count += 1;
break; //if you find one count it as a whole word
}
}
word = String::new();
@@ -113,6 +114,7 @@ impl Stats {
for forbidden_word in FORBIDDEN_WORDS {
if lowercase_word.contains(forbidden_word) {
self.forbidden_count += 1;
break; //if you find one count it as a whole word
}
}
word = String::new();
@@ -161,6 +163,7 @@ impl Stats {
for forbidden_word in FORBIDDEN_WORDS {
if lowercase_word.contains(forbidden_word) {
self.forbidden_count += 1;
break; //if you find one count it as a whole word
}
}
}