Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat: improve spell check suggestions by accounting for common misspellings (#1245)

Michael Schmidt1e2c6c332a96
diff --git a/harper-core/src/linting/spell_check.rs b/harper-core/src/linting/spell_check.rs
index 67e5b4fb9..9e5d0f242 100644
--- a/harper-core/src/linting/spell_check.rs
+++ b/harper-core/src/linting/spell_check.rs
@@ -6,7 +6,10 @@ use smallvec::ToSmallVec;
use super::Suggestion;
use super::{Lint, LintKind, Linter};
use crate::document::Document;
-use crate::spell::suggest_correct_spelling;
+use crate::spell::{
+ is_cksz_misspelling, is_er_misspelling, is_ll_misspelling, is_ou_misspelling,
+ suggest_correct_spelling,
+};
use crate::{CharString, CharStringExt, Dialect, Dictionary, TokenStringExt};
pub struct SpellCheck<T>
@@ -26,39 +29,43 @@ impl<T: Dictionary> SpellCheck<T> {
dialect,
}
}
-}
-impl<T: Dictionary> SpellCheck<T> {
- fn cached_suggest_correct_spelling(&mut self, word: &[char]) -> Vec<CharString> {
+ const MAX_SUGGESTIONS: usize = 3;
+
+ fn suggest_correct_spelling(&mut self, word: &[char]) -> Vec<CharString> {
if let Some(hit) = self.word_cache.get(word) {
- return hit.clone();
+ hit.clone()
+ } else {
+ let suggestions = self.uncached_suggest_correct_spelling(word);
+ self.word_cache.put(word.into(), suggestions.clone());
+ suggestions
}
-
+ }
+ fn uncached_suggest_correct_spelling(&self, word: &[char]) -> Vec<CharString> {
// Back off until we find a match.
- let mut suggestions = Vec::new();
- let mut dist = 2;
-
- while suggestions.is_empty() && dist < 5 {
- suggestions = suggest_correct_spelling(word, 100, dist, &self.dictionary)
- .into_iter()
- .map(|v| v.to_smallvec())
- .collect();
-
- dist += 1;
+ for dist in 2..5 {
+ let suggestions: Vec<CharString> =
+ suggest_correct_spelling(word, 100, dist, &self.dictionary)
+ .into_iter()
+ .filter(|v| {
+ // ignore entries outside the configured dialect
+ self.dictionary
+ .get_word_metadata(v)
+ .unwrap()
+ .dialect
+ .is_none_or(|d| d == self.dialect)
+ })
+ .map(|v| v.to_smallvec())
+ .take(Self::MAX_SUGGESTIONS)
+ .collect();
+
+ if !suggestions.is_empty() {
+ return suggestions;
+ }
}
- // Remove entries outside the configured dialect
- suggestions.retain(|v| {
- self.dictionary
- .get_word_metadata(v)
- .unwrap()
- .dialect
- .is_none_or(|d| d == self.dialect)
- });
-
- self.word_cache.put(word.into(), suggestions.clone());
-
- suggestions
+ // no suggestions found
+ Vec::new()
}
}
@@ -78,10 +85,16 @@ impl<T: Dictionary> Linter for SpellCheck<T> {
}
};
- let mut possibilities = self.cached_suggest_correct_spelling(word_chars);
-
- if possibilities.len() > 3 {
- possibilities.resize_with(3, || panic!());
+ let mut possibilities = self.suggest_correct_spelling(word_chars);
+ if let Some(most_likely) = possibilities.first() {
+ // If the most likely suggestion is a common misspelling, ignore all others.
+ if is_ou_misspelling(most_likely, word_chars)
+ || is_cksz_misspelling(most_likely, word_chars)
+ || is_er_misspelling(most_likely, word_chars)
+ || is_ll_misspelling(most_likely, word_chars)
+ {
+ possibilities.truncate(1);
+ }
}
// If the misspelled word is capitalized, capitalize the results too.
diff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rs
index a977c5320..09d1d7412 100644
--- a/harper-core/src/spell/mod.rs
+++ b/harper-core/src/spell/mod.rs
@@ -27,6 +27,162 @@ impl PartialOrd for FuzzyMatchResult<'_> {
}
}
+/// Returns whether the two words are the same, expect that one is written
+/// with 'ou' and the other with 'o'.
+///
+/// E.g. "color" and "colour"
+pub(crate) fn is_ou_misspelling(a: &[char], b: &[char]) -> bool {
+ if a.len().abs_diff(b.len()) != 1 {
+ return false;
+ }
+
+ let mut a_iter = a.iter();
+ let mut b_iter = b.iter();
+
+ loop {
+ match (
+ a_iter.next().map(char::to_ascii_lowercase),
+ b_iter.next().map(char::to_ascii_lowercase),
+ ) {
+ (Some('o'), Some('o')) => {
+ let mut a_next = a_iter.next().map(char::to_ascii_lowercase);
+ let mut b_next = b_iter.next().map(char::to_ascii_lowercase);
+ if a_next != b_next {
+ if a_next == Some('u') {
+ a_next = a_iter.next().map(char::to_ascii_lowercase);
+ } else if b_next == Some('u') {
+ b_next = b_iter.next().map(char::to_ascii_lowercase);
+ }
+
+ if a_next != b_next {
+ return false;
+ }
+ }
+ }
+ (Some(a_char), Some(b_char)) => {
+ if !a_char.eq_ignore_ascii_case(&b_char) {
+ return false;
+ }
+ }
+ (None, None) => return true,
+ _ => return false,
+ }
+ }
+}
+
+/// Returns whether the two words are the same, expect for a single confusion of:
+///
+/// - `s` and `z`. E.g."realize" and "realise"
+/// - `s` and `c`. E.g. "defense" and "defence"
+/// - `k` and `c`. E.g. "skepticism" and "scepticism"
+pub(crate) fn is_cksz_misspelling(a: &[char], b: &[char]) -> bool {
+ if a.len() != b.len() {
+ return false;
+ }
+ if a.is_empty() {
+ return true;
+ }
+
+ // the first character must be the same
+ if !a[0].eq_ignore_ascii_case(&b[0]) {
+ return false;
+ }
+
+ let mut found = false;
+ for (a_char, b_char) in a.iter().copied().zip(b.iter().copied()) {
+ let a_char = a_char.to_ascii_lowercase();
+ let b_char = b_char.to_ascii_lowercase();
+
+ if a_char != b_char {
+ if (a_char == 's' && b_char == 'z')
+ || (a_char == 'z' && b_char == 's')
+ || (a_char == 's' && b_char == 'c')
+ || (a_char == 'c' && b_char == 's')
+ || (a_char == 'k' && b_char == 'c')
+ || (a_char == 'c' && b_char == 'k')
+ {
+ if found {
+ return false;
+ }
+ found = true;
+ } else {
+ return false;
+ }
+ }
+ }
+
+ found
+}
+
+/// Returns whether the two words are the same, expect that one is written
+/// with '-er' and the other with '-re'.
+///
+/// E.g. "meter" and "metre"
+pub(crate) fn is_er_misspelling(a: &[char], b: &[char]) -> bool {
+ if a.len() != b.len() || a.len() <= 4 {
+ return false;
+ }
+
+ let len = a.len();
+ let a_suffix = [&a[len - 2], &a[len - 1]].map(char::to_ascii_lowercase);
+ let b_suffix = [&b[len - 2], &b[len - 1]].map(char::to_ascii_lowercase);
+
+ if a_suffix == ['r', 'e'] && b_suffix == ['e', 'r']
+ || a_suffix == ['e', 'r'] && b_suffix == ['r', 'e']
+ {
+ return a[0..len - 2]
+ .iter()
+ .copied()
+ .zip(b[0..len - 2].iter().copied())
+ .all(|(a_char, b_char)| a_char.eq_ignore_ascii_case(&b_char));
+ }
+
+ false
+}
+
+/// Returns whether the two words are the same, expect that one is written
+/// with 'll' and the other with 'l'.
+///
+/// E.g. "traveller" and "traveler"
+pub(crate) fn is_ll_misspelling(a: &[char], b: &[char]) -> bool {
+ if a.len().abs_diff(b.len()) != 1 {
+ return false;
+ }
+
+ let mut a_iter = a.iter();
+ let mut b_iter = b.iter();
+
+ loop {
+ match (
+ a_iter.next().map(char::to_ascii_lowercase),
+ b_iter.next().map(char::to_ascii_lowercase),
+ ) {
+ (Some('l'), Some('l')) => {
+ let mut a_next = a_iter.next().map(char::to_ascii_lowercase);
+ let mut b_next = b_iter.next().map(char::to_ascii_lowercase);
+ if a_next != b_next {
+ if a_next == Some('l') {
+ a_next = a_iter.next().map(char::to_ascii_lowercase);
+ } else if b_next == Some('l') {
+ b_next = b_iter.next().map(char::to_ascii_lowercase);
+ }
+
+ if a_next != b_next {
+ return false;
+ }
+ }
+ }
+ (Some(a_char), Some(b_char)) => {
+ if !a_char.eq_ignore_ascii_case(&b_char) {
+ return false;
+ }
+ }
+ (None, None) => return true,
+ _ => return false,
+ }
+ }
+}
+
/// Scores a possible spelling suggestion based on possible relevance to the user.
///
/// Lower = better.
@@ -51,7 +207,7 @@ fn score_suggestion(misspelled_word: &[char], sug: &FuzzyMatchResult) -> i32 {
score -= 5;
}
- // For turning words into contractions.
+ // Boost common words.
if sug.metadata.common {
score -= 5;
}
@@ -61,6 +217,18 @@ fn score_suggestion(misspelled_word: &[char], sug: &FuzzyMatchResult) -> i32 {
score -= 5;
}
+ // Detect dialect-specific variations
+ if sug.edit_distance == 1
+ && (is_cksz_misspelling(misspelled_word, sug.word)
+ || is_ou_misspelling(misspelled_word, sug.word)
+ || is_ll_misspelling(misspelled_word, sug.word))
+ {
+ score -= 5;
+ }
+ if sug.edit_distance == 2 && is_er_misspelling(misspelled_word, sug.word) {
+ score -= 15;
+ }
+
score
}
diff --git a/harper-core/tests/text/Spell.md b/harper-core/tests/text/Spell.md
new file mode 100644
index 000000000..c99fab039
--- /dev/null
+++ b/harper-core/tests/text/Spell.md
@@ -0,0 +1,13 @@
+# Spell
+
+This document contains example sentences with misspelled words that we want to test the spell checker on.
+
+## Example Sentences
+
+My favourite color is blu.
+I must defend my honour!
+I recognize that you recognise me.
+I analyze how you infantilize me.
+I analyse how you infantilise me.
+Careful, traveller!
+At the centre of the theatre I dropped a litre of coke.
diff --git a/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml b/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
index 417f31fbe..8a85ffdfa 100644
--- a/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
+++ b/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
@@ -88,11 +88,9 @@ Message: |
Lint: Spelling (63 priority)
Message: |
43 | shelves as she passed; it was labelled “ORANGE MARMALADE”, but to her great
- | ^~~~~~~~ Did you mean to spell `labelled` this way?
+ | ^~~~~~~~ Did you mean `labeled`?
Suggest:
- Replace with: “labeled”
- - Replace with: “labeler”
- - Replace with: “labelless”
@@ -100,11 +98,9 @@ Lint: Spelling (63 priority)
Message: |
54 | I’ve fallen by this time?” she said aloud. “I must be getting somewhere near the
55 | centre of the earth. Let me see: that would be four thousand miles down, I
- | ^~~~~~ Did you mean to spell `centre` this way?
+ | ^~~~~~ Did you mean `center`?
Suggest:
- - Replace with: “centred”
- - Replace with: “centres”
- - Replace with: “censure”
+ - Replace with: “center”
@@ -322,12 +318,10 @@ Message: |
Lint: Spelling (63 priority)
Message: |
138 | finding it very nice, (it had, in fact, a sort of mixed flavour of cherry-tart,
- | ^~~~~~~ Did you mean to spell `flavour` this way?
+ | ^~~~~~~ Did you mean `flavor`?
139 | custard, pine-apple, roast turkey, toffee, and hot buttered toast,) she very
Suggest:
- Replace with: “flavor”
- - Replace with: “flavours”
- - Replace with: “favor”
@@ -499,11 +493,9 @@ Lint: Spelling (63 priority)
Message: |
229 | “If you please, sir—” The Rabbit started violently, dropped the white kid gloves
230 | and the fan, and skurried away into the darkness as hard as he could go.
- | ^~~~~~~~ Did you mean to spell `skurried` this way?
+ | ^~~~~~~~ Did you mean `scurried`?
Suggest:
- Replace with: “scurried”
- - Replace with: “spurred”
- - Replace with: “scurries”
@@ -1046,22 +1038,18 @@ Lint: Spelling (63 priority)
Message: |
660 | voice she had never heard before, “Sure then I’m here! Digging for apples, yer
661 | honour!”
- | ^~~~~~ Did you mean to spell `honour` this way?
+ | ^~~~~~ Did you mean `honor`?
Suggest:
- Replace with: “honor”
- - Replace with: “honours”
- - Replace with: “honour's”
Lint: Spelling (63 priority)
Message: |
668 | “Sure, it’s an arm, yer honour!” (He pronounced it “arrum.”)
- | ^~~~~~ Did you mean to spell `honour` this way?
+ | ^~~~~~ Did you mean `honor`?
Suggest:
- Replace with: “honor”
- - Replace with: “honours”
- - Replace with: “honour's”
@@ -1079,22 +1067,18 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
672 | “Sure, it does, yer honour: but it’s an arm for all that.”
- | ^~~~~~ Did you mean to spell `honour` this way?
+ | ^~~~~~ Did you mean `honor`?
Suggest:
- Replace with: “honor”
- - Replace with: “honours”
- - Replace with: “honour's”
Lint: Spelling (63 priority)
Message: |
677 | then; such as, “Sure, I don’t like it, yer honour, at all, at all!” “Do as I
- | ^~~~~~ Did you mean to spell `honour` this way?
+ | ^~~~~~ Did you mean `honor`?
Suggest:
- Replace with: “honor”
- - Replace with: “honours”
- - Replace with: “honour's”
@@ -1708,12 +1692,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
1497 | The Hatter shook his head mournfully. “Not I!” he replied. “We quarrelled last
- | ^~~~~~~~~~ Did you mean to spell `quarrelled` this way?
+ | ^~~~~~~~~~ Did you mean `quarreled`?
1498 | March—just before he went mad, you know—” (pointing with his tea spoon at the
Suggest:
- Replace with: “quarreled”
- - Replace with: “quarreler”
- - Replace with: “quarrellers”
@@ -1847,11 +1829,9 @@ Lint: Spelling (63 priority)
Message: |
1713 | they were all ornamented with hearts. Next came the guests, mostly Kings and
1714 | Queens, and among them Alice recognised the White Rabbit: it was talking in a
- | ^~~~~~~~~~ Did you mean to spell `recognised` this way?
+ | ^~~~~~~~~~ Did you mean `recognized`?
Suggest:
- Replace with: “recognized”
- - Replace with: “recogniser”
- - Replace with: “recognises”
@@ -2158,7 +2138,7 @@ Message: |
Suggest:
- Replace with: “this”
- Replace with: “ti's”
- - Replace with: “tbs”
+ - Replace with: “tic”
@@ -2170,7 +2150,7 @@ Message: |
Suggest:
- Replace with: “this”
- Replace with: “ti's”
- - Replace with: “tbs”
+ - Replace with: “tic”
@@ -2214,11 +2194,9 @@ Lint: Spelling (63 priority)
Message: |
2048 | But here, to Alice’s great surprise, the Duchess’s voice died away, even in the
2049 | middle of her favourite word ‘moral,’ and the arm that was linked into hers
- | ^~~~~~~~~ Did you mean to spell `favourite` this way?
+ | ^~~~~~~~~ Did you mean `favorite`?
Suggest:
- Replace with: “favorite”
- - Replace with: “favourites”
- - Replace with: “favourite's”
@@ -3296,11 +3274,9 @@ Lint: Spelling (63 priority)
Message: |
2547 | even make out that one of them didn’t know how to spell “stupid,” and that he
2548 | had to ask his neighbour to tell him. “A nice muddle their slates’ll be in
- | ^~~~~~~~~ Did you mean to spell `neighbour` this way?
+ | ^~~~~~~~~ Did you mean `neighbor`?
Suggest:
- Replace with: “neighbor”
- - Replace with: “neighbours”
- - Replace with: “neighbour's”
@@ -3621,12 +3597,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
2988 | noises, would change (she knew) to the confused clamour of the busy
- | ^~~~~~~ Did you mean to spell `clamour` this way?
+ | ^~~~~~~ Did you mean `clamor`?
2989 | farm-yard—while the lowing of the cattle in the distance would take the place of
Suggest:
- Replace with: “clamor”
- - Replace with: “clamours”
- - Replace with: “glamour”
diff --git a/harper-core/tests/text/linters/Difficult sentences.snap.yml b/harper-core/tests/text/linters/Difficult sentences.snap.yml
index a498f20da..99d7ba20e 100644
--- a/harper-core/tests/text/linters/Difficult sentences.snap.yml
+++ b/harper-core/tests/text/linters/Difficult sentences.snap.yml
@@ -28,11 +28,9 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
56 | He was protected by his body armour.
- | ^~~~~~ Did you mean to spell `armour` this way?
+ | ^~~~~~ Did you mean `armor`?
Suggest:
- - Replace with: “amour”
- Replace with: “armor”
- - Replace with: “armours”
@@ -88,11 +86,9 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
208 | My aim in travelling there was to find my missing friend.
- | ^~~~~~~~~~ Did you mean to spell `travelling` this way?
+ | ^~~~~~~~~~ Did you mean `traveling`?
Suggest:
- Replace with: “traveling”
- - Replace with: “travellings”
- - Replace with: “travelling's”
@@ -129,11 +125,9 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
258 | I need to keep in with the neighbours in case I ever need a favour from them.
- | ^~~~~~ Did you mean to spell `favour` this way?
+ | ^~~~~~ Did you mean `favor`?
Suggest:
- Replace with: “favor”
- - Replace with: “favours”
- - Replace with: “famous”
@@ -159,11 +153,9 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
284 | This behaviour is typical of teenagers.
- | ^~~~~~~~~ Did you mean to spell `behaviour` this way?
+ | ^~~~~~~~~ Did you mean `behavior`?
Suggest:
- Replace with: “behavior”
- - Replace with: “behaviours”
- - Replace with: “behaviour's”
@@ -267,22 +259,18 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
366 | He travelled on false documents.
- | ^~~~~~~~~ Did you mean to spell `travelled` this way?
+ | ^~~~~~~~~ Did you mean `traveled`?
Suggest:
- Replace with: “traveled”
- - Replace with: “traveler”
- - Replace with: “travailed”
Lint: Spelling (63 priority)
Message: |
398 | Who am I to criticise? I've done worse things myself.
- | ^~~~~~~~~ Did you mean to spell `criticise` this way?
+ | ^~~~~~~~~ Did you mean `criticize`?
Suggest:
- - Replace with: “criticism”
- Replace with: “criticize”
- - Replace with: “criticised”
diff --git a/harper-core/tests/text/linters/Part-of-speech tagging.snap.yml b/harper-core/tests/text/linters/Part-of-speech tagging.snap.yml
index 80f31240e..d0257eb94 100644
--- a/harper-core/tests/text/linters/Part-of-speech tagging.snap.yml
+++ b/harper-core/tests/text/linters/Part-of-speech tagging.snap.yml
@@ -588,12 +588,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
201 | algorithm, Brill tagger, Constraint Grammar, and the Baum-Welch algorithm (also
- | ^~~~~ Did you mean to spell `Welch` this way?
+ | ^~~~~ Did you mean `Welsh`?
202 | known as the forward-backward algorithm). Hidden Markov model and visible Markov
Suggest:
- Replace with: “Welsh”
- - Replace with: “Belch”
- - Replace with: “Walsh”
diff --git a/harper-core/tests/text/linters/Spell.snap.yml b/harper-core/tests/text/linters/Spell.snap.yml
new file mode 100644
index 000000000..c5eba8a80
--- /dev/null
+++ b/harper-core/tests/text/linters/Spell.snap.yml
@@ -0,0 +1,92 @@
+Lint: Spelling (63 priority)
+Message: |
+ 7 | My favourite color is blu.
+ | ^~~~~~~~~ Did you mean `favorite`?
+Suggest:
+ - Replace with: “favorite”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 7 | My favourite color is blu.
+ | ^~~ Did you mean to spell `blu` this way?
+Suggest:
+ - Replace with: “bl”
+ - Replace with: “blue”
+ - Replace with: “blur”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 8 | I must defend my honour!
+ | ^~~~~~ Did you mean `honor`?
+Suggest:
+ - Replace with: “honor”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 9 | I recognize that you recognise me.
+ | ^~~~~~~~~ Did you mean `recognize`?
+Suggest:
+ - Replace with: “recognize”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 11 | I analyse how you infantilise me.
+ | ^~~~~~~ Did you mean `analyze`?
+Suggest:
+ - Replace with: “analyze”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 11 | I analyse how you infantilise me.
+ | ^~~~~~~~~~~ Did you mean `infantilize`?
+Suggest:
+ - Replace with: “infantilize”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 12 | Careful, traveller!
+ | ^~~~~~~~~ Did you mean `traveler`?
+Suggest:
+ - Replace with: “traveler”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 13 | At the centre of the theatre I dropped a litre of coke.
+ | ^~~~~~ Did you mean `center`?
+Suggest:
+ - Replace with: “center”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 13 | At the centre of the theatre I dropped a litre of coke.
+ | ^~~~~~~ Did you mean `theater`?
+Suggest:
+ - Replace with: “theater”
+
+
+
+Lint: Spelling (63 priority)
+Message: |
+ 13 | At the centre of the theatre I dropped a litre of coke.
+ | ^~~~~ Did you mean `liter`?
+Suggest:
+ - Replace with: “liter”
+
+
+
diff --git a/harper-core/tests/text/linters/The Constitution of the United States.snap.yml b/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
index d685d343a..8a1dfdac6 100644
--- a/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
+++ b/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
@@ -16,12 +16,10 @@ Message: |
Lint: Spelling (63 priority)
Message: |
6 | establish Justice, insure domestic Tranquility, provide for the common defence,
- | ^~~~~~~ Did you mean to spell `defence` this way?
+ | ^~~~~~~ Did you mean `defense`?
7 | promote the general Welfare, and secure the Blessings of Liberty to ourselves
Suggest:
- Replace with: “defense”
- - Replace with: “decency”
- - Replace with: “deface”
@@ -531,12 +529,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
203 | Imposts and Excises, to pay the Debts and provide for the common Defence and
- | ^~~~~~~ Did you mean to spell `Defence` this way?
+ | ^~~~~~~ Did you mean `Defense`?
204 | general Welfare of the United States; but all Duties, Imposts and Excises shall
Suggest:
- Replace with: “Defense”
- - Replace with: “Fence”
- - Replace with: “Terence”
@@ -1464,11 +1460,9 @@ Lint: Spelling (63 priority)
Message: |
627 | States, or any place subject to their jurisdiction. No Person held to Service
628 | or Labour in one State, under the Laws thereof, escaping into another, shall,
- | ^~~~~~ Did you mean to spell `Labour` this way?
+ | ^~~~~~ Did you mean `Labor`?
Suggest:
- Replace with: “Labor”
- - Replace with: “Labours”
- - Replace with: “About”
@@ -1476,11 +1470,9 @@ Lint: Spelling (63 priority)
Message: |
629 | in Consequence of any Law or Regulation therein, be discharged from such
630 | Service or Labour, but shall be delivered up on Claim of the Party to whom such
- | ^~~~~~ Did you mean to spell `Labour` this way?
+ | ^~~~~~ Did you mean `Labor`?
Suggest:
- Replace with: “Labor”
- - Replace with: “Labours”
- - Replace with: “About”
@@ -1488,11 +1480,9 @@ Lint: Spelling (63 priority)
Message: |
630 | Service or Labour, but shall be delivered up on Claim of the Party to whom such
631 | Service or Labour may be due.
- | ^~~~~~ Did you mean to spell `Labour` this way?
+ | ^~~~~~ Did you mean `Labor`?
Suggest:
- Replace with: “Labor”
- - Replace with: “Labours”
- - Replace with: “About”
@@ -1655,11 +1645,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
714 | first Page, The Word "Thirty" being partly written on an Erazure in the
- | ^~~~~~~ Did you mean to spell `Erazure` this way?
+ | ^~~~~~~ Did you mean `Erasure`?
715 | fifteenth Line of the first Page. The Words "is tried" being interlined between
Suggest:
- Replace with: “Erasure”
- - Replace with: “Azure”
diff --git a/harper-core/tests/text/linters/The Great Gatsby.snap.yml b/harper-core/tests/text/linters/The Great Gatsby.snap.yml
index 5a87b360a..fa9ce9352 100644
--- a/harper-core/tests/text/linters/The Great Gatsby.snap.yml
+++ b/harper-core/tests/text/linters/The Great Gatsby.snap.yml
@@ -203,12 +203,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
61 | restless. Instead of being the warm centre of the world, the Middle West now
- | ^~~~~~ Did you mean to spell `centre` this way?
+ | ^~~~~~ Did you mean `center`?
62 | seemed like the ragged edge of the universe—so I decided to go East and learn
Suggest:
- - Replace with: “centred”
- - Replace with: “centres”
- - Replace with: “censure”
+ - Replace with: “center”
@@ -341,12 +339,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
120 | was a factual imitation of some Hôtel de Ville in Normandy, with a tower on one
- | ^~~~~ Did you mean to spell `Ville` this way?
+ | ^~~~~ Did you mean `Vile`?
121 | side, spanking new under a thin beard of raw ivy, and a marble swimming pool,
Suggest:
- Replace with: “Vile”
- - Replace with: “Villa”
- - Replace with: “Lille”
@@ -687,11 +683,9 @@ Lint: Spelling (63 priority)
Message: |
479 | thinking, but I doubt if even Miss Baker, who seemed to have mastered a certain
480 | hardy scepticism, was able utterly to put this fifth guest’s shrill metallic
- | ^~~~~~~~~~ Did you mean to spell `scepticism` this way?
+ | ^~~~~~~~~~ Did you mean `skepticism`?
Suggest:
- Replace with: “skepticism”
- - Replace with: “sceptic's”
- - Replace with: “scepticism's”
@@ -1226,11 +1220,9 @@ Lint: Spelling (63 priority)
Message: |
923 | “I should change the light,” he said after a moment. “I’d like to bring out the
924 | modelling of the features. And I’d try to get hold of all the back hair.”
- | ^~~~~~~~~ Did you mean to spell `modelling` this way?
+ | ^~~~~~~~~ Did you mean `modeling`?
Suggest:
- Replace with: “modeling”
- - Replace with: “modellings”
- - Replace with: “modelling's”
@@ -1506,7 +1498,7 @@ Message: |
Suggest:
- Replace with: “hers”
- Replace with: “ho's”
- - Replace with: “hobs”
+ - Replace with: “hours”
@@ -1604,12 +1596,10 @@ Lint: Spelling (63 priority)
Message: |
1202 | confident girls who weave here and there among the stouter and more stable,
1203 | become for a sharp, joyous moment the centre of a group, and then, excited with
- | ^~~~~~ Did you mean to spell `centre` this way?
+ | ^~~~~~ Did you mean `center`?
1204 | triumph, glide on through the sea-change of faces and voices and color under the
Suggest:
- - Replace with: “centred”
- - Replace with: “centres”
- - Replace with: “censure”
+ - Replace with: “center”
@@ -1710,22 +1700,18 @@ Lint: Spelling (63 priority)
Message: |
1347 | chance we tried an important-looking door, and walked into a high Gothic
1348 | library, panelled with carved English oak, and probably transported complete
- | ^~~~~~~~ Did you mean to spell `panelled` this way?
+ | ^~~~~~~~ Did you mean `paneled`?
Suggest:
- Replace with: “paneled”
- - Replace with: “palled”
- - Replace with: “Janelle”
Lint: Spelling (63 priority)
Message: |
1373 | Taking our scepticism for granted, he rushed to the bookcases and returned with
- | ^~~~~~~~~~ Did you mean to spell `scepticism` this way?
+ | ^~~~~~~~~~ Did you mean `skepticism`?
Suggest:
- Replace with: “skepticism”
- - Replace with: “sceptic's”
- - Replace with: “scepticism's”
@@ -2116,12 +2102,10 @@ Lint: Spelling (63 priority)
Message: |
1764 | Again at eight o’clock, when the dark lanes of the Forties were lined five deep
1765 | with throbbing taxicabs, bound for the theatre district, I felt a sinking in my
- | ^~~~~~~ Did you mean to spell `theatre` this way?
+ | ^~~~~~~ Did you mean `theater`?
1766 | heart. Forms leaned together in the taxis as they waited, and voices sang, and
Suggest:
- - Replace with: “theatres”
- Replace with: “theater”
- - Replace with: “theatre's”
@@ -3087,11 +3071,9 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
2011 | “Major Jay Gatsby,” I read, “For Valour Extraordinary.”
- | ^~~~~~ Did you mean to spell `Valour` this way?
+ | ^~~~~~ Did you mean `Valor`?
Suggest:
- Replace with: “Valor”
- - Replace with: “Valium”
- - Replace with: “Valois”
@@ -3154,11 +3136,9 @@ Lint: Spelling (63 priority)
Message: |
2076 | Europe, and I was glad that the sight of Gatsby’s splendid car was included in
2077 | their sombre holiday. As we crossed Blackwell’s Island a limousine passed us,
- | ^~~~~~ Did you mean to spell `sombre` this way?
+ | ^~~~~~ Did you mean `somber`?
Suggest:
- - Replace with: “hombre”
- Replace with: “somber”
- - Replace with: “some”
@@ -3691,12 +3671,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
2455 | hard, limited person, who dealt in universal scepticism, and who leaned back
- | ^~~~~~~~~~ Did you mean to spell `scepticism` this way?
+ | ^~~~~~~~~~ Did you mean `skepticism`?
2456 | jauntily just within the circle of my arm. A phrase began to beat in my ears
Suggest:
- Replace with: “skepticism”
- - Replace with: “sceptic's”
- - Replace with: “scepticism's”
@@ -4433,10 +4411,9 @@ Message: |
Lint: Spelling (63 priority)
Message: |
3254 | “I’m looking around. I’m having a marvellous—”
- | ^~~~~~~~~~ Did you mean to spell `marvellous` this way?
+ | ^~~~~~~~~~ Did you mean `marvelous`?
Suggest:
- Replace with: “marvelous”
- - Replace with: “marvellously”
@@ -4485,11 +4462,9 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
3319 | at the local club to-morrow, spoke in Miss Baedeker’s defence:
- | ^~~~~~~ Did you mean to spell `defence` this way?
+ | ^~~~~~~ Did you mean `defense`?
Suggest:
- Replace with: “defense”
- - Replace with: “decency”
- - Replace with: “deface”
@@ -4745,11 +4720,9 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
3599 | Gatsby stood in the centre of the crimson carpet and gazed around with
- | ^~~~~~ Did you mean to spell `centre` this way?
+ | ^~~~~~ Did you mean `center`?
Suggest:
- - Replace with: “centred”
- - Replace with: “centres”
- - Replace with: “censure”
+ - Replace with: “center”
@@ -5128,12 +5101,10 @@ Suggest:
Lint: Spelling (63 priority)
Message: |
3975 | could invent a protest the coupé came to a stop, and Daisy signalled us to draw
- | ^~~~~~~~~ Did you mean to spell `signalled` this way?
+ | ^~~~~~~~~ Did you mean `signaled`?
3976 | up alongside.
Suggest:
- Replace with: “signaled”
- - Replace with: “signaler”
- - Replace with: “signalised”
diff --git a/harper-core/tests/text/tagged/Spell.md b/harper-core/tests/text/tagged/Spell.md
new file mode 100644
index 000000000..daea83cf7
--- /dev/null
+++ b/harper-core/tests/text/tagged/Spell.md
@@ -0,0 +1,26 @@
+> Spell
+# NSg/V
+>
+#
+> This document contains example sentences with misspelled words that we want to test the spell checker on .
+# I/D NSg/V V NSg/V NPl/V P V/J NPl/V N/I/C/D IPl NSg/V P NSg/V D NSg NSg/V J/P .
+>
+#
+> Example Sentences
+# NSg/V NPl/V
+>
+#
+> My favourite color is blu .
+# D NSg/J/Br NSg/V/J/Am VL W? .
+> I must defend my honour !
+# ISg NSg/V NSg/V D NSg/Br .
+> I recognize that you recognise me .
+# ISg V N/I/C/D IPl V/Br NPrSg/ISg .
+> I analyze how you infantilize me .
+# ISg V NSg/C IPl V NPrSg/ISg .
+> I analyse how you infantilise me .
+# ISg V/Br NSg/C IPl ? NPrSg/ISg .
+> Careful , traveller !
+# J . NSg/Br .
+> At the centre of the theatre I dropped a litre of coke .
+# P D NSg/Br P D NSg/Br ISg V/J D/P NSg/Br P NPrSg/V .
diff --git a/packages/vscode-plugin/src/tests/suite/integration.test.ts b/packages/vscode-plugin/src/tests/suite/integration.test.ts
index 1673d7fdd..a72351496 100644
--- a/packages/vscode-plugin/src/tests/suite/integration.test.ts
+++ b/packages/vscode-plugin/src/tests/suite/integration.test.ts
@@ -46,7 +46,7 @@ describe('Integration >', () => {
range: createRange(2, 26, 2, 32),
},
{
- message: 'Did you mean to spell `realise` this way?',
+ message: 'Did you mean `realize`?',
range: createRange(4, 26, 4, 33),
},
),
@@ -112,7 +112,7 @@ describe('Integration >', () => {
range: createRange(2, 26, 2, 32),
},
{
- message: 'Did you mean to spell `realise` this way?',
+ message: 'Did you mean `realize`?',
range: createRange(4, 26, 4, 33),
},
),