Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: now a days→nowadays; add to discourse markers (#3392)
Andrew Dunbar887d2d9c829b
diff --git a/harper-core/default_config.json b/harper-core/default_config.jsonindex 92c686e6a..789409d94 100644--- a/harper-core/default_config.json+++ b/harper-core/default_config.json@@ -1331,6 +1331,13 @@"label": "Expand Vulnerability"}},+ {+ "Bool": {+ "name": "Nowadays",+ "state": true,+ "label": "Nowadays"+ }+ },{"Bool": {"name": "ConstituteAs",diff --git a/harper-core/src/linting/discourse_markers.rs b/harper-core/src/linting/discourse_markers.rsindex 88ad8392a..03e0b77d2 100644--- a/harper-core/src/linting/discourse_markers.rs+++ b/harper-core/src/linting/discourse_markers.rs@@ -13,29 +13,32 @@ pub struct DiscourseMarkers {impl DiscourseMarkers {pub fn new() -> Self {let phrases = &[- "however",- "therefore",- "meanwhile",- "furthermore",- "nevertheless",- "consequently",- "thus",- "instead",- "moreover",- "honestly",- "alternatively",- "frankly",- "additionally",- "subsequently","accordingly",- "otherwise",- "incidentally",+ "additionally",+ "alternatively",+ "consequently","conversely",- "notwithstanding",+ "for example",+ "frankly",+ "furthermore","hence",+ "honestly",+ "however",+ "incidentally","indeed",- "for example",+ "instead",+ "meanwhile",+ "moreover",+ "nevertheless",+ "notwithstanding",+ "nowadays",+ "now a days",+ "now-a-days","on the other hand",+ "otherwise",+ "subsequently",+ "therefore",+ "thus",];let phrases_expr = FirstMatchOf::new(@@ -304,4 +307,46 @@ mod tests {DiscourseMarkers::default(),);}++ #[test]+ fn corrects_nowadays() {+ assert_suggestion_result(+ "Nowadays E-Commerce is one of the hot topics.",+ DiscourseMarkers::default(),+ "Nowadays, E-Commerce is one of the hot topics.",+ );+ }++ #[test]+ fn no_suggestion_if_nowadays_not_at_start() {+ assert_no_lints(+ "You are the reason the tech state is awful nowadays",+ DiscourseMarkers::default(),+ );+ }++ #[test]+ fn corrects_now_a_days() {+ assert_suggestion_result(+ "Now a days Automation plays a crucial role in mankind.",+ DiscourseMarkers::default(),+ "Now a days, Automation plays a crucial role in mankind.",+ );+ }++ #[test]+ fn no_suggestion_if_comma_after_nowadays() {+ assert_no_lints(+ "Nowadays, data has become the most valuable part of any individual or organization.",+ DiscourseMarkers::default(),+ );+ }++ #[test]+ fn no_suggestion_if_comma_after_now_a_days() {+ assert_no_lints(+ "Now a days, movie recommendation systems are well developed and are user focused.",+ DiscourseMarkers::default(),+ );+ }}diff --git a/harper-core/src/linting/phrase_set_corrections/mod.rs b/harper-core/src/linting/phrase_set_corrections/mod.rsindex cfa1c801a..8808081ea 100644--- a/harper-core/src/linting/phrase_set_corrections/mod.rs+++ b/harper-core/src/linting/phrase_set_corrections/mod.rs@@ -895,6 +895,21 @@ pub fn lint_group() -> LintGroup {"Corrects `no only` to `not only` before forms of `to be`.",LintKind::Grammar),+ "Nowadays" => (+ &[(+ &[+ "now a days", "now-a-days", "now a day's",+ "nowaday", "now a day", "now-a-day",+ "now adays", "now-adays", "now aday's",+ "now aday",+ "nowa days",+ ],+ &["nowadays"]+ )],+ "Use `nowadays` instead of common misspellings.",+ "Corrects common misspellings of `nowadays`.",+ LintKind::Usage+ ),"RiseTheQuestion" => (&[(&["rise the question", "arise the question"], &["raise the question"]),diff --git a/harper-core/src/linting/phrase_set_corrections/tests.rs b/harper-core/src/linting/phrase_set_corrections/tests.rsindex c6ded0a60..a58abc312 100644--- a/harper-core/src/linting/phrase_set_corrections/tests.rs+++ b/harper-core/src/linting/phrase_set_corrections/tests.rs@@ -4,6 +4,14 @@ use crate::linting::tests::{use super::lint_group;+/// Helper function to create a lint group with only a single rule enabled.+fn single_lint(rule_name: &str) -> crate::linting::LintGroup {+ let mut group = lint_group();+ group.set_all_rules_to(None); // Disable all linters+ group.config.set_rule_enabled(rule_name, true); // Enable only the specified rule+ group+}+// 1:1 tests// Ado@@ -826,15 +834,9 @@ fn corrects_vuln() {#[test]fn corrects_vulns() {// Fix just this lint- let mut only_expand_vuln = lint_group();- only_expand_vuln.set_all_rules_to(None); // Disable all linters- only_expand_vuln- .config- .set_rule_enabled("ExpandVulnerability", true); // Enable only ExpandVuln-assert_suggestion_result("... when persisted, containing endpoints, vulns, WAF bypasses, sensitive params, and auth endpoints.",- only_expand_vuln,+ single_lint("ExpandVulnerability"),"... when persisted, containing endpoints, vulnerabilities, WAF bypasses, sensitive params, and auth endpoints.",);// Fix all lints in the `LintGroup`@@ -1956,11 +1958,20 @@ fn fix_everybody_seams() {fn fix_everyone_seams() {assert_suggestion_result("everyone seams to use the editor now a days plus there is a tun of extensions available",- lint_group(),+ single_lint("SeamToSeem"),"everyone seems to use the editor now a days plus there is a tun of extensions available",);}+#[test]+fn fix_everyone_seams_combined_with_now_a_days() {+ assert_suggestion_result(+ "everyone seams to use the editor now a days plus there is a tun of extensions available",+ lint_group(),+ "everyone seems to use the editor nowadays plus there is a tun of extensions available",+ );+}+// SubjunctiveWasToWere// -if only there was-@@ -3011,6 +3022,107 @@ fn fix_no_only_were() {);}+// Nowadays++#[test]+fn fix_now_a_days_spaces() {+ assert_suggestion_result(+ "Now a days, movie recommendation systems are well developed and are user focused.",+ lint_group(),+ "Nowadays, movie recommendation systems are well developed and are user focused.",+ );+}++#[test]+fn fix_now_a_days_apostrophe() {+ assert_suggestion_result(+ "Now a day's recognizing the activity from the surveillance video is a challenging task.",+ lint_group(),+ "Nowadays recognizing the activity from the surveillance video is a challenging task.",+ );+}++#[test]+fn fix_now_a_days_hyphen() {+ assert_suggestion_result(+ "Recommendation engines are now a one of the most common Machine Learning project that can be seen now-a-days.",+ lint_group(),+ "Recommendation engines are now a one of the most common Machine Learning project that can be seen nowadays.",+ );+}++#[test]+fn fix_now_a_day() {+ assert_suggestion_result(+ "Now a day a calendar is a daily essential things.",+ lint_group(),+ "Nowadays a calendar is a daily essential things.",+ );+}++#[test]+fn fix_now_a_day_hyphen() {+ assert_suggestion_result(+ "Now-a-day, lots of people prefer ordering food online to save their time and effort.",+ lint_group(),+ "Nowadays, lots of people prefer ordering food online to save their time and effort.",+ );+}++#[test]+fn fix_now_adays_hyphen() {+ assert_suggestion_result(+ "@andyp1per knows most about those Python scripts now-adays.",+ lint_group(),+ "@andyp1per knows most about those Python scripts nowadays.",+ );+}++#[test]+fn fix_now_adays_space() {+ assert_suggestion_result(+ "Coding is one of my fav thing to do now adays.!",+ lint_group(),+ "Coding is one of my fav thing to do nowadays.!",+ );+}++#[test]+fn fix_nowaday() {+ assert_suggestion_result(+ "nowaday, I have to capitalize the first letter of the name gets from @babel/types.",+ lint_group(),+ "nowadays, I have to capitalize the first letter of the name gets from @babel/types.",+ );+}++#[test]+fn fix_now_adays_apostrophe() {+ assert_suggestion_result(+ "I believe CSS clamp has great browser support now aday's as well.",+ lint_group(),+ "I believe CSS clamp has great browser support nowadays as well.",+ );+}++#[test]+fn fix_nowa_days() {+ assert_suggestion_result(+ "But discord would be great cause discord is universally used for all games and companies and schools nowa days.",+ lint_group(),+ "But discord would be great cause discord is universally used for all games and companies and schools nowadays.",+ );+}++#[test]+fn fix_now_aday() {+ assert_suggestion_result(+ "OF all Occupations that now aday is used,I would not be a butcher",+ lint_group(),+ "OF all Occupations that nowadays is used,I would not be a butcher",+ );+}+// RaiseTheQuestion// -raise the question-diff --git a/harper-core/tests/text/linters/The Great Gatsby.snap.yml b/harper-core/tests/text/linters/The Great Gatsby.snap.ymlindex 3c01f4bb3..e32d0dfe2 100644--- a/harper-core/tests/text/linters/The Great Gatsby.snap.yml+++ b/harper-core/tests/text/linters/The Great Gatsby.snap.yml@@ -5510,6 +5510,16 @@ Message: |+Lint: Punctuation (31 priority)+Message: |+ 4149 | the idea you can count me out. . . . Nowadays people begin by sneering at family+ | ^~~~~~~~ Discourse markers at the beginning of a sentence should be followed by a comma.+ 4150 | life and family institutions, and next they’ll throw everything overboard and+Suggest:+ - Insert “,”+++Lint: Formatting (255 priority)Message: |4175 | me.”