Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(core): issue #661 by disallowing words that could be adjectives
Elijah Potterb451b92ca872
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dictindex 241a87835..340219a62 100644--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@ -31530,7 +31530,7 @@ maximization/1Mmaximize/4GDSmaximum/15SMmay/41M-maybe/51SM+maybe/5j1SMmayday/1MSmayflower/1MSmayfly/1SMdiff --git a/harper-core/src/linting/closed_compounds.rs b/harper-core/src/linting/closed_compounds.rsindex 50b2725bc..4ceaa393d 100644--- a/harper-core/src/linting/closed_compounds.rs+++ b/harper-core/src/linting/closed_compounds.rs@@ -98,6 +98,8 @@ create_closed_compound_linter!(Henceforth, "hence forth", "henceforth");create_closed_compound_linter!(Regardless, "regard less", "regardless");create_closed_compound_linter!(Overnight, "over night", "overnight");create_closed_compound_linter!(Furthermore, "further more", "furthermore");+create_closed_compound_linter!(Laptop, "lap top", "laptop");+create_closed_compound_linter!(Desktop, "desk top", "desktop");#[cfg(test)]mod tests {diff --git a/harper-core/src/linting/compound_nouns/general_compound_nouns.rs b/harper-core/src/linting/compound_nouns/general_compound_nouns.rsindex 9f560cc62..d499ec32d 100644--- a/harper-core/src/linting/compound_nouns/general_compound_nouns.rs+++ b/harper-core/src/linting/compound_nouns/general_compound_nouns.rs@@ -36,7 +36,9 @@ impl Default for GeneralCompoundNouns {tok.span.len() > 1 && !meta.article && !meta.is_adverb() && !meta.preposition}));- let split_pattern = Lrc::new(SplitCompoundWord::new(|meta| meta.is_noun()));+ let split_pattern = Lrc::new(SplitCompoundWord::new(|meta| {+ meta.is_noun() && !meta.is_adjective()+ }));let mut pattern = All::default();pattern.add(Box::new(split_pattern.clone()));diff --git a/harper-core/src/linting/compound_nouns/mod.rs b/harper-core/src/linting/compound_nouns/mod.rsindex 86f8d0780..f5989d428 100644--- a/harper-core/src/linting/compound_nouns/mod.rs+++ b/harper-core/src/linting/compound_nouns/mod.rs@@ -13,13 +13,6 @@ mod tests {use super::CompoundNouns;use crate::linting::tests::{assert_lint_count, assert_suggestion_result};- #[test]- fn lap_top() {- let test_sentence = "I bought a lap top yesterday.";- let expected = "I bought a laptop yesterday.";- assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);- }-#[test]fn web_cam() {let test_sentence = "The web cam captured a stunning image.";@@ -48,13 +41,6 @@ mod tests {assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}- #[test]- fn desk_top() {- let test_sentence = "The company provided each employee with a desk top computer.";- let expected = "The company provided each employee with a desktop computer.";- assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);- }-#[test]fn firm_ware() {let test_sentence = "The device's firm ware was updated overnight.";@@ -209,13 +195,6 @@ mod tests {assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);}- #[test]- fn hand_held() {- let test_sentence = "The camera has a comfortable hand held design.";- let expected = "The camera has a comfortable handheld design.";- assert_suggestion_result(test_sentence, CompoundNouns::default(), expected);- }-#[test]fn play_ground() {let test_sentence = "The kids spent the afternoon at the play ground.";@@ -271,4 +250,9 @@ mod tests {0,);}++ #[test]+ fn allow_issue_661() {+ assert_lint_count("I may be wrong.", CompoundNouns::default(), 0);+ }}diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rsindex 027347549..fe1a5471e 100644--- a/harper-core/src/linting/lint_group.rs+++ b/harper-core/src/linting/lint_group.rs@@ -6,7 +6,9 @@ use super::avoid_curses::AvoidCurses;use super::boring_words::BoringWords;use super::capitalize_personal_pronouns::CapitalizePersonalPronouns;use super::chock_full::ChockFull;+use super::closed_compounds::Desktop;use super::closed_compounds::Furthermore;+use super::closed_compounds::Laptop;use super::closed_compounds::Overnight;use super::closed_compounds::{Anybody, Anyhow, Anywhere, Backplane, Devops, Everywhere, Henceforth, However, Insofar,@@ -176,6 +178,8 @@ macro_rules! create_lint_group_config {}create_lint_group_config!(+ Desktop => true,+ Laptop => true,Furthermore => true,Overnight => true,Hereby => true,diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rsindex ae6e66a7a..776662b01 100644--- a/harper-core/src/linting/mod.rs+++ b/harper-core/src/linting/mod.rs@@ -56,7 +56,9 @@ pub use avoid_curses::AvoidCurses;pub use boring_words::BoringWords;pub use capitalize_personal_pronouns::CapitalizePersonalPronouns;pub use chock_full::ChockFull;+pub use closed_compounds::Desktop;pub use closed_compounds::Furthermore;+pub use closed_compounds::Laptop;pub use closed_compounds::Overnight;pub use closed_compounds::{Anybody, Anyhow, Anywhere, Backplane, Devops, Everywhere, Henceforth, However, Insofar,