Skip to content

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.dict
index 33e98cc68..de30b245f 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -23315,7 +23315,7 @@ farming/~154M
farmland/~1MS
farmstead/~1MS
farmyard/1MS
-faro/~1M
+faro/1M
farrago/1M
farragoes/1
farrier/14MS
@@ -24215,7 +24215,7 @@ fondness/~1M
fondue/14SM
font/~14MS
fontanel/1MS
-foo/~1
+foo/1
foobar/1
food/~1MS
foodie/1SM
@@ -24512,7 +24512,7 @@ foxtrotting/4
foxy/15RTP
foyer/~1SM
fps/~1
-fr/~514
+fr/514
fracas/1MS
frack/45SDG
fractal/~15SM
@@ -24688,7 +24688,6 @@ frivolousness/1M
frizz/41MDSYG
frizzle/41MGDS
frizzy/51TR
-fro/~+1
frock's
frock/14CUS
frog/~14MS
diff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rs
index 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;