mirror of
https://github.com/crate-ci/typos.git
synced 2024-11-25 02:20:58 -05:00
test(dict): Help prevent correctin valid words
This dictionary was taken from OpenOfice
This commit is contained in:
parent
47dd297604
commit
285e5f633c
3 changed files with 47818 additions and 18 deletions
47791
crates/typos-dict/assets/english.csv
vendored
Normal file
47791
crates/typos-dict/assets/english.csv
vendored
Normal file
File diff suppressed because it is too large
Load diff
3
crates/typos-dict/assets/words.csv
vendored
3
crates/typos-dict/assets/words.csv
vendored
|
@ -6362,7 +6362,6 @@ barbarisch,barbaric
|
||||||
barbedos,barbados
|
barbedos,barbados
|
||||||
barberians,barbarians
|
barberians,barbarians
|
||||||
barcelets,bracelets
|
barcelets,bracelets
|
||||||
barceloneta,barcelona
|
|
||||||
barcleona,barcelona
|
barcleona,barcelona
|
||||||
bardford,bradford
|
bardford,bradford
|
||||||
bareclona,barcelona
|
bareclona,barcelona
|
||||||
|
@ -57862,7 +57861,6 @@ thunderbowl,thunderbolt
|
||||||
thunderjolt,thunderbolt
|
thunderjolt,thunderbolt
|
||||||
thunderolt,thunderbolt
|
thunderolt,thunderbolt
|
||||||
thundervolt,thunderbolt
|
thundervolt,thunderbolt
|
||||||
thur,their
|
|
||||||
thurday,thursday
|
thurday,thursday
|
||||||
thurdsay,thursday
|
thurdsay,thursday
|
||||||
thurdsays,thursdays
|
thurdsays,thursdays
|
||||||
|
@ -62486,7 +62484,6 @@ wednessday,wednesdays,wednesday
|
||||||
wednsday,wednesday
|
wednsday,wednesday
|
||||||
wednseday,wednesday
|
wednseday,wednesday
|
||||||
wednsedays,wednesdays
|
wednsedays,wednesdays
|
||||||
wee,we
|
|
||||||
weerd,weird
|
weerd,weird
|
||||||
weerdly,weirdly
|
weerdly,weirdly
|
||||||
weev,weave
|
weev,weave
|
||||||
|
|
Can't render this file because it is too large.
|
|
@ -164,7 +164,7 @@ fn test_duplicate_correction_removal() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cycle_removal() {
|
fn test_cycle_removal() {
|
||||||
assert!(process([("foo", ["bar"]), ("bar", ["foo"])]).is_empty());
|
assert!(process([("foo", ["foobar"]), ("foobar", ["foo"])]).is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -243,20 +243,32 @@ fn find_best_match<'c>(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allowed_words() -> std::collections::HashMap<String, String> {
|
fn allowed_words() -> std::collections::HashMap<String, String> {
|
||||||
let allowed_path = "assets/allowed.csv";
|
let allowed_path = "assets/english.csv";
|
||||||
let data = std::fs::read(allowed_path).unwrap();
|
let english_data = std::fs::read(allowed_path).unwrap();
|
||||||
csv::ReaderBuilder::new()
|
let mut allowed_english = csv::ReaderBuilder::new()
|
||||||
.has_headers(false)
|
.has_headers(false)
|
||||||
.flexible(true)
|
.flexible(true)
|
||||||
.from_reader(data.as_slice())
|
.from_reader(english_data.as_slice());
|
||||||
.records()
|
let allowed_english = allowed_english.records().map(Result::unwrap).map(|r| {
|
||||||
.map(Result::unwrap)
|
let mut i = r.iter();
|
||||||
.map(|r| {
|
let mut typo = i.next().expect("typo").to_owned();
|
||||||
let mut i = r.iter();
|
typo.make_ascii_lowercase();
|
||||||
let mut typo = i.next().expect("typo").to_owned();
|
(typo, String::from("english word"))
|
||||||
typo.make_ascii_lowercase();
|
});
|
||||||
let reason = i.next().expect("reason").to_owned();
|
|
||||||
(typo, reason)
|
let allowed_path = "assets/allowed.csv";
|
||||||
})
|
let local_data = std::fs::read(allowed_path).unwrap();
|
||||||
.collect()
|
let mut allowed_local = csv::ReaderBuilder::new()
|
||||||
|
.has_headers(false)
|
||||||
|
.flexible(true)
|
||||||
|
.from_reader(local_data.as_slice());
|
||||||
|
let allowed_local = allowed_local.records().map(Result::unwrap).map(|r| {
|
||||||
|
let mut i = r.iter();
|
||||||
|
let mut typo = i.next().expect("typo").to_owned();
|
||||||
|
typo.make_ascii_lowercase();
|
||||||
|
let reason = i.next().expect("reason").to_owned();
|
||||||
|
(typo, reason)
|
||||||
|
});
|
||||||
|
|
||||||
|
allowed_english.chain(allowed_local).collect()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue