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 854a1c3991
commit 12f2494411
2 changed files with 36 additions and 2 deletions
jest_rust

View File

@ -116,6 +116,22 @@ capitalized word percentage: 2%
benchmark: 5033ms
```
count forbidden word once only:
```
file count: 904
failed file count: 0
sentence count: 5602301
word count: 81701260
capitalized count: 1753639
numeric count: 14981248
forbidden count: 1143234
words per sentence average: 14.6
forbidden word percentage: 1%
capitalized word percentage: 2%
benchmark: 4737ms
```
muncher:
```
file count: 904
@ -130,4 +146,19 @@ forbidden word percentage: 0%
capitalized word percentage: 16%
benchmark: 504ms
```
with forbidden words:
```
file count: 904
failed file count: 0
sentence count: 5338705
word count: 86765116
capitalized count: 13640820
numeric count: 10902254
forbidden count: 279717
words per sentence average: 16.3
forbidden word percentage: 0%
capitalized word percentage: 16%
benchmark: 6078ms
```

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
}
}
}