Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
chore(core): more `matcher` conversions
Elijah Potter161021dd168d
diff --git a/harper-core/src/linting/matcher.rs b/harper-core/src/linting/matcher.rsindex d8a4447fd..7016af0c4 100644--- a/harper-core/src/linting/matcher.rs+++ b/harper-core/src/linting/matcher.rs@@ -103,16 +103,6 @@ impl Matcher {// defined like it is now.let mut triggers = Vec::new();- // hyphenated phrases- triggers.extend(pt! {- "case", "sensitive" => "case-sensitive",- "chock","full" => "chock-full",- "ngram" => "n-gram",- "off","the","cuff" => "off-the-cuff",- "Tree", "sitter" => "Tree-sitter",- "wellbeing" => "well-being"- });-// expand abbreviationstriggers.extend(pt! {"dep" => "dependency",@@ -144,27 +134,7 @@ impl Matcher {triggers.extend(pt! {"performing","this" => "perform this","simply","grammatical" => "simple grammatical",- "the","challenged" => "that challenged",- "to", "towards" => "towards",- "To-Do" => "To-do",- "todo" => "to-do"- });-- // wrong set phrases and collocations- triggers.extend(pt! {- "discuss", "about" => "discuss",- "discussed", "about" => "discussed",- "discusses", "about" => "discusses",- "discussing", "about" => "discussing"- });-- // normalization- triggers.extend(pt! {- "world","war","2" => "World War II",- "world","War","ii" => "World War II",- "World","war","ii" => "World War II",- "World","War","iI" => "World War II",- "World","War","Ii" => "World War II"+ "the","challenged" => "that challenged"});// countries and capitals with special casing or punctuationdiff --git a/harper-core/src/linting/phrase_corrections.rs b/harper-core/src/linting/phrase_corrections.rsindex 32807db04..8e0fe2845 100644--- a/harper-core/src/linting/phrase_corrections.rs+++ b/harper-core/src/linting/phrase_corrections.rs@@ -502,7 +502,91 @@ pub fn lint_group() -> LintGroup {["whet your appetite"],"Use the correct phrase for stimulating desire.","Ensures `whet your appetite` is used correctly, distinguishing it from the incorrect `wet` variation."- )+ ),+ "CaseSensitive" => (+ ["case sensitive"],+ ["case-sensitive"],+ "Use the hyphenated form for `case-sensitive`.",+ "Ensures `case-sensitive` is correctly hyphenated."+ ),+ "ChockFull" => (+ ["chock full"],+ ["chock-full"],+ "Use the hyphenated form for `chock-full`.",+ "Ensures `chock-full` is correctly hyphenated."+ ),+ "OffTheCuff" => (+ ["off the cuff"],+ ["off-the-cuff"],+ "Use the hyphenated form for `off-the-cuff`.",+ "Ensures `off-the-cuff` is correctly hyphenated."+ ),+ "WellBeing" => (+ ["wellbeing"],+ ["well-being"],+ "Use the hyphenated form for `well-being`.",+ "Ensures `well-being` is correctly hyphenated."+ ),+ "PerformThis" => (+ ["performing this"],+ ["perform this"],+ "Use `perform this` for correct verb usage.",+ "Corrects `performing this` to `perform this` for proper verb usage."+ ),+ "SimpleGrammatical" => (+ ["simply grammatical"],+ ["simple grammatical"],+ "Use `simple grammatical` for correct adjective usage.",+ "Corrects `simply grammatical` to `simple grammatical` for proper adjective usage."+ ),+ "ThatChallenged" => (+ ["the challenged"],+ ["that challenged"],+ "Use `that challenged` for correct relative clause.",+ "Corrects `the challenged` to `that challenged` for proper relative clause usage."+ ),+ "ToDoHyphen" => (+ ["todo"],+ ["to-do"],+ "Hyphenate `to-do`.",+ "Ensures `to-do` is correctly hyphenated."+ ),+ "Discuss" => (+ ["discuss about"],+ ["discuss"],+ "`About` is redundant",+ "Removes unnecessary `about` after `discuss`."+ ),+ "Discussed" => (+ ["discussed about"],+ ["discussed"],+ "Use `discussed` without `about`.",+ "Removes unnecessary `about` after `discussed`."+ ),+ "Discusses" => (+ ["discusses about"],+ ["discusses"],+ "`About` is redundant",+ "Removes unnecessary `about` after `discusses`."+ ),+ "Discussing" => (+ ["discussing about"],+ ["discussing"],+ "`About` is redundant",+ "Removes unnecessary `about` after `discussing`."+ ),+ "WorldWarII" => (+ ["world war 2", "world war ii", "world war ii", "world war ii", "world war ii"],+ ["World War II"],+ "Use the correct capitalization for `World War II`.",+ "Ensures `World War II` is correctly capitalized."+ ),+ "Towards" => (+ ["to towards"],+ ["towards"],+ "Use `towards` without preceding `to`.",+ "Removes redundant `to` before `towards`."+ ),});group.set_all_rules_to(Some(true));diff --git a/harper-core/src/patterns/any_capitalization.rs b/harper-core/src/patterns/any_capitalization.rsindex 01c4b6fd2..d8b9ee0c4 100644--- a/harper-core/src/patterns/any_capitalization.rs+++ b/harper-core/src/patterns/any_capitalization.rs@@ -29,12 +29,12 @@ impl Pattern for AnyCapitalization {return 0;}- let tok_chars = tok.span.get_content(source);-- if tok_chars.len() != self.word.len() {+ if tok.span.len() != self.word.len() {return 0;}+ let tok_chars = tok.span.get_content(source);+let partial_match = tok_chars.iter().zip(&self.word)