Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(core): adjust spellcheck to prioritize the first letter
Elijah Potterae5e59952689
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dictindex 33e98cc68..de30b245f 100644--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@ -23315,7 +23315,7 @@ farming/~154Mfarmland/~1MSfarmstead/~1MSfarmyard/1MS-faro/~1M+faro/1Mfarrago/1Mfarragoes/1farrier/14MS@@ -24215,7 +24215,7 @@ fondness/~1Mfondue/14SMfont/~14MSfontanel/1MS-foo/~1+foo/1foobar/1food/~1MSfoodie/1SM@@ -24512,7 +24512,7 @@ foxtrotting/4foxy/15RTPfoyer/~1SMfps/~1-fr/~514+fr/514fracas/1MSfrack/45SDGfractal/~15SM@@ -24688,7 +24688,6 @@ frivolousness/1Mfrizz/41MDSYGfrizzle/41MGDSfrizzy/51TR-fro/~+1frock'sfrock/14CUSfrog/~14MSdiff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rsindex 01bf27794..dd96db310 100644--- a/harper-core/src/spell/mod.rs+++ b/harper-core/src/spell/mod.rs@@ -37,6 +37,11 @@ fn score_suggestion(misspelled_word: &[char], sug: &FuzzyMatchResult) -> i32 {let mut score = sug.edit_distance as i32 * 10;+ // People are much less likely to mistype the first letter.+ if misspelled_word.first().unwrap() == sug.word.first().unwrap() {+ score -= 10;+ }+// If the original word is plural, the correct one probably is too.if *misspelled_word.last().unwrap() == 's' && *sug.word.last().unwrap() == 's' {score -= 5;