Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable ability to have numbers in English checker #174

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/checkers/english.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ fn normalise_string(input: &str) -> String {
.to_ascii_lowercase()
.chars()
.filter(|x| !x.is_ascii_punctuation())
// if digit is base10 filter it out
// Our dictionary does not contain numbers, so we want to filter them out
.filter(|x| !x.is_digit(10))
.collect()
}

Expand Down Expand Up @@ -187,4 +190,10 @@ mod tests {
let checker = Checker::<EnglishChecker>::new();
assert!(!checker.check("#").is_identified);
}

#[test]
fn test_check_fail_single_number() {
let checker = Checker::<EnglishChecker>::new();
assert!(!checker.check("2").is_identified);
}
}
3 changes: 3 additions & 0 deletions src/storage/dictionaries/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
f = open(file_name)
f2 = open("modified.txt", "w")
for line in f:
line = line.strip()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of our words when opened in file mode had spaces in them, this messed up my analysis of them which led to some single chars (a) being included because their length was actually > 2 due to having multiple spaces

if len(line) <= MIN_LENGTH:
continue
if len(set(line).intersection(PUNC)) != 0:
continue
if not line.isalpha():
continue
if LOWERCASE:
line = line.lower()
f2.write(line)
Expand Down
Loading