Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat(core): add a bunch more closed compounds
Elijah Potterc948b3635e1f
diff --git a/harper-core/src/linting/closed_compounds.rs b/harper-core/src/linting/closed_compounds.rsindex 08e5ffa6f..9f6a8cb65 100644--- a/harper-core/src/linting/closed_compounds.rs+++ b/harper-core/src/linting/closed_compounds.rs@@ -54,10 +54,27 @@ macro_rules! create_closed_compound_linter {}create_closed_compound_linter!(Itself, "it self", "itself");+create_closed_compound_linter!(Tonight, "to night", "tonight");+create_closed_compound_linter!(Myself, "my self", "myself");+create_closed_compound_linter!(Therefore, "there fore", "therefore");+create_closed_compound_linter!(Misunderstand, "miss understand", "misunderstand");+create_closed_compound_linter!(Misunderstood, "miss understood", "misunderstood");+create_closed_compound_linter!(Misuse, "miss use", "misuse");+create_closed_compound_linter!(Misused, "miss used", "misused");+create_closed_compound_linter!(Postpone, "post pone", "postpone");+create_closed_compound_linter!(Worldwide, "world wide", "worldwide");+create_closed_compound_linter!(Overall, "over all", "overall");+create_closed_compound_linter!(Likewise, "like wise", "likewise");+create_closed_compound_linter!(However, "how ever", "however");+create_closed_compound_linter!(Altogether, "all together", "altogether");+create_closed_compound_linter!(Asleep, "a sleep", "asleep");#[cfg(test)]mod tests {- use super::Itself;+ use super::{+ Altogether, Asleep, However, Itself, Likewise, Misunderstood, Misuse, Misused, Myself,+ Overall, Therefore, Tonight, Worldwide,+ };use crate::linting::tests::assert_suggestion_result;#[test]@@ -66,4 +83,88 @@ mod tests {let expected = "The project, itself, was quite challenging.";assert_suggestion_result(test_sentence, Itself::default(), expected);}++ #[test]+ fn to_night() {+ let test_sentence = "She spent the night to night.";+ let expected = "She spent the night tonight.";+ assert_suggestion_result(test_sentence, Tonight::default(), expected);+ }++ #[test]+ fn my_self() {+ let test_sentence = "He treated my self with respect.";+ let expected = "He treated myself with respect.";+ assert_suggestion_result(test_sentence, Myself::default(), expected);+ }++ #[test]+ fn there_fore() {+ let test_sentence = "This is the reason; there fore, this is true.";+ let expected = "This is the reason; therefore, this is true.";+ assert_suggestion_result(test_sentence, Therefore::default(), expected);+ }++ #[test]+ fn mis_understood() {+ let test_sentence = "She miss understood the instructions.";+ let expected = "She misunderstood the instructions.";+ assert_suggestion_result(test_sentence, Misunderstood::default(), expected);+ }++ #[test]+ fn mis_use() {+ let test_sentence = "He tends to miss use the tool.";+ let expected = "He tends to misuse the tool.";+ assert_suggestion_result(test_sentence, Misuse::default(), expected);+ }++ #[test]+ fn mis_used() {+ let test_sentence = "The software was miss used.";+ let expected = "The software was misused.";+ assert_suggestion_result(test_sentence, Misused::default(), expected);+ }++ #[test]+ fn world_wide() {+ let test_sentence = "The world wide impact was significant.";+ let expected = "The worldwide impact was significant.";+ assert_suggestion_result(test_sentence, Worldwide::default(), expected);+ }++ #[test]+ fn over_all() {+ let test_sentence = "The over all performance was good.";+ let expected = "The overall performance was good.";+ assert_suggestion_result(test_sentence, Overall::default(), expected);+ }++ #[test]+ fn like_wise() {+ let test_sentence = "He acted, like wise, without hesitation.";+ let expected = "He acted, likewise, without hesitation.";+ assert_suggestion_result(test_sentence, Likewise::default(), expected);+ }++ #[test]+ fn how_ever() {+ let test_sentence = "This is true, how ever, details matter.";+ let expected = "This is true, however, details matter.";+ assert_suggestion_result(test_sentence, However::default(), expected);+ }++ #[test]+ fn all_together() {+ let test_sentence = "They did it all together.";+ let expected = "They did it altogether.";+ assert_suggestion_result(test_sentence, Altogether::default(), expected);+ }++ #[test]+ fn a_sleep() {+ let test_sentence = "She fell a sleep.";+ let expected = "She fell asleep.";+ assert_suggestion_result(test_sentence, Asleep::default(), expected);+ }}diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rsindex b0229154c..4b79f5517 100644--- a/harper-core/src/linting/lint_group.rs+++ b/harper-core/src/linting/lint_group.rs@@ -5,7 +5,21 @@ use super::an_a::AnA;use super::avoid_curses::AvoidCurses;use super::boring_words::BoringWords;use super::capitalize_personal_pronouns::CapitalizePersonalPronouns;+use super::closed_compounds::Altogether;+use super::closed_compounds::Asleep;+use super::closed_compounds::However;use super::closed_compounds::Itself;+use super::closed_compounds::Likewise;+use super::closed_compounds::Misunderstand;+use super::closed_compounds::Misunderstood;+use super::closed_compounds::Misuse;+use super::closed_compounds::Misused;+use super::closed_compounds::Myself;+use super::closed_compounds::Overall;+use super::closed_compounds::Postpone;+use super::closed_compounds::Therefore;+use super::closed_compounds::Tonight;+use super::closed_compounds::Worldwide;use super::correct_number_suffix::CorrectNumberSuffix;use super::despite_of::DespiteOf;use super::dot_initialisms::DotInitialisms;@@ -162,6 +176,20 @@ macro_rules! create_lint_group_config {}create_lint_group_config!(+ Misunderstood => true,+ Asleep => true,+ Altogether => true,+ However => true,+ Likewise => true,+ Overall => true,+ Worldwide => true,+ Postpone => true,+ Misused => true,+ Misuse => true,+ Misunderstand => true,+ Therefore => true,+ Myself => true,+ Tonight => true,Itself => true,Whereas => true,SpelledNumbers => false,diff --git a/harper-core/src/linting/matcher.rs b/harper-core/src/linting/matcher.rsindex b8ca04b95..c44fe0d3b 100644--- a/harper-core/src/linting/matcher.rs+++ b/harper-core/src/linting/matcher.rs@@ -109,7 +109,6 @@ impl Matcher {"deps" => "dependencies","off","the","cuff" => "off-the-cuff","an","in" => "and in",- "my","self" => "myself","eight","grade" => "eighth grade","and","also" => "and","todo" => "to-do",@@ -132,7 +131,6 @@ impl Matcher {"No","to" => "not to","ngram" => "n-gram","grammer" => "grammar",- "There","fore" => "Therefore","fatal","outcome" => "death","geiger","counter" => "Geiger counter","world","war","2" => "World War II",@@ -149,9 +147,6 @@ impl Matcher {"can","be","seem" => "can be seen","mu","house" => "my house","kid","regards" => "kind regards",- "miss","understand" => "misunderstand",- "miss","use" => "misuse",- "miss","used" => "misused","bee","there" => "been there","want","be" => "won't be","more","then" => "more than",@@ -162,8 +157,6 @@ impl Matcher {"then","him" => "than him","then","his" => "than his","simply","grammatical" => "simple grammatical",- "you","r" => "your",- "you","re" => "you're","ms" => "milliseconds","case", "sensitive" => "case-sensitive","Tree", "sitter" => "Tree-sitter",@@ -255,17 +248,3 @@ impl Linter for Matcher {"A collection of curated rules. A catch-all that will be removed in the future."}}--#[cfg(test)]-mod tests {- use super::{Linter, Matcher};- use crate::Document;-- #[test]- fn matches_therefore() {- let document = Document::new_plain_english_curated("There fore.");- let mut matcher = Matcher::new();- let lints = matcher.lint(&document);- assert_eq!(lints.len(), 1);- }-}diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rsindex 8d97673b1..8ce338309 100644--- a/harper-core/src/linting/mod.rs+++ b/harper-core/src/linting/mod.rs@@ -48,6 +48,20 @@ pub use an_a::AnA;pub use avoid_curses::AvoidCurses;pub use boring_words::BoringWords;pub use capitalize_personal_pronouns::CapitalizePersonalPronouns;+pub use closed_compounds::Altogether;+pub use closed_compounds::Asleep;+pub use closed_compounds::However;+pub use closed_compounds::Likewise;+pub use closed_compounds::Misunderstand;+pub use closed_compounds::Misunderstood;+pub use closed_compounds::Misuse;+pub use closed_compounds::Misused;+pub use closed_compounds::Myself;+pub use closed_compounds::Overall;+pub use closed_compounds::Postpone;+pub use closed_compounds::Therefore;+pub use closed_compounds::Tonight;+pub use closed_compounds::Worldwide;pub use correct_number_suffix::CorrectNumberSuffix;pub use currency_placement::CurrencyPlacement;pub use despite_of::DespiteOf;