Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
Merge branch 'master' into matcher-conversions
Elijah Potterc39a61ed7cdb
diff --cc harper-core/dictionary.dictindex 46ce8ac0c,81638d941..992b23715--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@@ -49802,8 -49846,5 +49849,10 @@@ KSQL/PRQL/1MapReduce/1SQLAlchemy/1+inclusivity/SM+touchpad/SM+bitstream/SM+backplane/SM+cyberattack/SM+ RTX/1SM+ PDP/1SMdiff --cc harper-core/src/linting/lint_group.rsindex f2b0e964b,c45faf3a0..8c000c979--- a/harper-core/src/linting/lint_group.rs+++ b/harper-core/src/linting/lint_group.rs@@@ -30,10 -18,11 +30,11 @@@ use super::nobody::Nobodyuse super::number_suffix_capitalization::NumberSuffixCapitalization;use super::phrase_corrections::{AndAlike, BadRap, BatedBreath, BeckAndCall, ChangeTack, EnMasse, HumanLife, HungerPang,- LetAlone, LoAndBehold, NeedHelp, NoLonger, OfCourse, SneakingSuspicion, SupposedTo,- ThatChallenged, TurnItOff,+ LetAlone, LoAndBehold, NeedHelp, NoLonger, OfCourse, SneakingSuspicion, SpecialAttention,- SupposeTo, ThanOthers, ThatChallenged, TurnItOff,++ SupposedTo, ThanOthers, ThatChallenged, TurnItOff,};use super::plural_conjugate::PluralConjugate;+ use super::possessive_your::PossessiveYour;use super::pronoun_contraction::PronounContraction;use super::proper_noun_capitalization_linters::{AmazonNames, Americas, AppleNames, AzureNames, ChineseCommunistParty, GoogleNames, Holidays,@@@ -173,53 -161,7 +174,54 @@@ macro_rules! create_lint_group_config}create_lint_group_config!(+ Overnight => true,+ Hereby => true,+ Likewise => true,+ CompoundNouns => true,+ Regardless => true,+ Henceforth => true,+ Upward => true,+ Whereupon => true,+ Insofar => true,+ Thereupon => true,+ Nonetheless => true,+ Anyhow => true,+ Notwithstanding => true,+ Widespread => true,+ Multimedia => true,+ Multicore => true,+ Multithreading => true,+ Devops => true,+ Underclock => true,+ Overload => true,+ Backplane => true,+ Overclocking => true,+ Middleware => true,+ Somewhere => true,+ Instead => true,+ Anywhere => true,+ Nothing => true,+ Anybody => true,+ Somebody => true,+ Nobody => true,+ Into => true,+ Proofread => true,+ Somehow => true,+ Intact => true,+ Upset => true,+ Misunderstood => true,+ However => true,+ Overall => true,+ Worldwide => true,+ Postpone => true,+ Misused => true,+ Misuse => true,+ Misunderstand => true,+ Therefore => true,+ Myself => true,+ Itself => true,+ Whereas => true,+ PossessiveYour => true,SpelledNumbers => false,AnA => true,SentenceCapitalization => true,@@@ -277,10 -219,7 +279,10 @@@LetAlone => true,LoAndBehold => true,SneakingSuspicion => true,- SupposeTo => true,+ SpecialAttention => true,+ Everywhere => true,+ ThanOthers => true,+ SupposedTo => true);impl<T: Dictionary + Default> Default for LintGroup<T> {diff --cc harper-core/src/linting/matcher.rsindex 2d6b67495,dc83c521f..b034adf2c--- a/harper-core/src/linting/matcher.rs+++ b/harper-core/src/linting/matcher.rs@@@ -101,73 -101,153 +101,128 @@@ impl Matcherpub fn new() -> Self {// This match list needs to be automatically expanded instead of explicitly// defined like it is now.- let mut triggers = pt! {- "wellbeing" => "well-being",- "hashtable" => "hash table",- "hashmap" => "hash map",- "dep" => "dependency",- "deps" => "dependencies",- "off","the","cuff" => "off-the-cuff",+ let mut triggers = Vec::new();++ // stylistic improvements+ triggers.extend(pt! {+ "all", "of", "the" => "all the",+ "and","also" => "and"+ });++ // phrase typos, each word passes spellcheck but one word is wrong+ triggers.extend(pt! {"an","in" => "and in",+ "bee","there" => "been there",+ "can","be","seem" => "can be seen","eight","grade" => "eighth grade",- "and","also" => "and",- "todo" => "to-do",- "To-Do" => "To-do",- "performing","this" => "perform this",- "mins" => "minutes",- "min" => "minute",+ "gong","to" => "going to",+ "I","a","m" => "I am",+ "It","cam" => "It can",+ "kid","regards" => "kind regards",+ "mu","house" => "my house",+ "no","to" => "not to",+ "No","to" => "not to",- "spacial","attention" => "special attention",+ "the", "this" => "that this",+ "The","re" => "There",- "There","fore" => "Therefore",- "though", "process" => "thought process",- "We","a","re" => "We are",- "you","r" => "your",- "you","re" => "you're"++ "though", "process" => "thought process"+ });++ // phrase capitalization+ triggers.extend(pt! {+ "black","sea" => "Black Sea",+ "geiger","counter" => "Geiger counter",+ "my","french" => "my French"+ });++ // hyphenate phrasal adjectives+ triggers.extend(pt! {+ "case", "sensitive" => "case-sensitive",+ "ngram" => "n-gram",+ "off","the","cuff" => "off-the-cuff",+ "Tree", "sitter" => "Tree-sitter",+ "wellbeing" => "well-being"+ });++ // expand abbreviations+ triggers.extend(pt! {+ "dep" => "dependency",+ "deps" => "dependencies",+ "hr" => "hour",+ "hrs" => "hours","min" => "minimum",- "secs" => "seconds",+ "min" => "minute",+ "mins" => "minutes",+ "ms" => "milliseconds","sec" => "second",- "hrs" => "hours",- "hr" => "hour",- "w/o" => "without",- "w/" => "with",- "wordlist" => "word list",- "the","challenged" => "that challenged",+ "secs" => "seconds","stdin" => "standard input","stdout" => "standard output",- "no","to" => "not to",- "No","to" => "not to",- "ngram" => "n-gram",- "grammer" => "grammar",- "fatal","outcome" => "death",- "geiger","counter" => "Geiger counter",- "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",- "black","sea" => "Black Sea",- "I","a","m" => "I am",- "The","re" => "There",- "my","french" => "my French",- "It","cam" => "It can",- "can","be","seem" => "can be seen",- "mu","house" => "my house",- "kid","regards" => "kind regards",- "bee","there" => "been there",- "want","be" => "won't be",+ "w/" => "with",+ "w/o" => "without"+ });++ // replace euphemisms+ triggers.extend(pt! {+ "fatal","outcome" => "death"+ });++ // spellos+ triggers.extend(pt! {+ "grammer" => "grammar"+ });++ // expand compound words+ triggers.extend(pt! {+ "hashmap" => "hash map",+ "hashtable" => "hash table",+ "wordlist" => "word list"+ });+- // prefixes written as separate words- triggers.extend(pt! {- "miss","understand" => "misunderstand",- "miss","use" => "misuse",- "miss","used" => "misused",- "my","self" => "myself"- });-+ // mixing up than/then in context+ triggers.extend(pt! {"more","then" => "more than",- "gong","to" => "going to",- "then","last","week" => "than last week",- "then","before" => "than before",- "Then","before" => "than before","then","her" => "than her","then","hers" => "than hers","then","him" => "than him","then","his" => "than his",- "then","last","week" => "than last week",- "then","others" => "than others",- "Then","others" => "than others"++ "then","last","week" => "than last week"+ });++ // not a perfect fit for any of the other categories+ triggers.extend(pt! {+ "performing","this" => "perform this","simply","grammatical" => "simple grammatical",- "ms" => "milliseconds",- "case", "sensitive" => "case-sensitive",- "Tree", "sitter" => "Tree-sitter",- "all", "of", "the" => "all the",+ "the","challenged" => "that challenged","to", "towards" => "towards",- "though", "process" => "thought process",- "the", "this" => "that this",+ "To-Do" => "To-do",+ "todo" => "to-do"+ });++ // wrong set phrases and collocations+ triggers.extend(pt! {"same", "than" => "same as",- "Same", "than" => "same as",+ "Same", "than" => "same as"+ });++ // belonging to multiple of the other categories+ triggers.extend(pt! {"same", "then" => "same as","Same", "then" => "same as"- };+ });+- // suffixes written as separate words- triggers.extend(pt! {- "that","s" => "that is",- "That","s" => "that is",- "that","s" => "that's",- "That","s" => "That's"- });-+ // near homophones+ triggers.extend(pt! {+ "want","be" => "won't be"+ });++ // 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"+ });triggers.push(Rule {pattern: vec![pt!("L"), pt!(Period), pt!("L"), pt!(Period), pt!("M")],diff --cc harper-core/src/linting/mod.rsindex 0907f067e,c0fa9c003..52b799fc6--- a/harper-core/src/linting/mod.rs+++ b/harper-core/src/linting/mod.rs@@@ -85,10 -68,11 +86,11 @@@ pub use oxford_comma::OxfordCommapub use pattern_linter::PatternLinter;pub use phrase_corrections::{AndAlike, BadRap, BatedBreath, BeckAndCall, ChangeTack, EnMasse, HumanLife, HungerPang,- LetAlone, LoAndBehold, NeedHelp, NoLonger, OfCourse, SneakingSuspicion, SupposedTo,- ThatChallenged, TurnItOff,+ LetAlone, LoAndBehold, NeedHelp, NoLonger, OfCourse, SneakingSuspicion, SpecialAttention,- SupposeTo, ThanOthers, ThatChallenged, TurnItOff,++ SupposedTo, ThanOthers, ThatChallenged, TurnItOff,};pub use plural_conjugate::PluralConjugate;+ pub use possessive_your::PossessiveYour;pub use pronoun_contraction::PronounContraction;pub use proper_noun_capitalization_linters::{AmazonNames, Americas, AppleNames, AzureNames, ChineseCommunistParty, GoogleNames, Holidays,diff --cc harper-core/src/linting/phrase_corrections.rsindex 4c832dbf5,f0d9ab94f..5aa4adb93--- a/harper-core/src/linting/phrase_corrections.rs+++ b/harper-core/src/linting/phrase_corrections.rs@@@ -83,9 -83,7 +83,9 @@@ create_linter_for_phrase!(EnMasse, "encreate_linter_for_phrase!(LetAlone, "let alone", 1);create_linter_for_phrase!(LoAndBehold, "lo and behold", 2);create_linter_for_phrase!(SneakingSuspicion, "sneaking suspicion", 3);- create_linter_for_phrase!(SupposeTo, "suppose to", 1);+create_linter_for_phrase!(SpecialAttention, "special attention", 1);+create_linter_for_phrase!(ThanOthers, "than others", 1);+ create_linter_for_phrase!(SupposedTo, "supposed to", 1);#[cfg(test)]mod tests {@@@ -93,7 -91,7 +93,7 @@@use super::{BadRap, BatedBreath, ChangeTack, EnMasse, HungerPang, LetAlone, LoAndBehold, OfCourse,- SneakingSuspicion, SpecialAttention, SupposeTo, ThanOthers, TurnItOff,- SneakingSuspicion, SupposedTo, TurnItOff,++ SneakingSuspicion, SpecialAttention, SupposedTo, ThanOthers, TurnItOff,};#[test]@@@ -185,20 -183,6 +185,20 @@@#[test]fn supposed_to() {- assert_suggestion_result("supposed to", SupposeTo::default(), "suppose to");+ assert_suggestion_result("suppose to", SupposedTo::default(), "supposed to");}++ #[test]+ fn spacial_attention() {+ assert_suggestion_result(+ "spacial attention",+ SpecialAttention::default(),+ "special attention",+ );+ }++ #[test]+ fn than_others() {+ assert_suggestion_result("Then others", ThanOthers::default(), "Than others");+ }}diff --cc justfileindex b1c78679d,35d8233ac..ee1512225--- a/justfile+++ b/justfile@@@ -291,12 -291,12 +291,22 @@@ fuzzfidone+registerlinter module name:+ #! /bin/bash++ D="{{justfile_directory()}}/harper-core/src/linting"++ sed -i "/pub use an_a::AnA;/a pub use {{module}}::{{name}};" "$D/mod.rs"+ sed -i "/use super::an_a::AnA;/a use super::{{module}}::{{name}};" "$D/lint_group.rs"+ sed -i "/create_lint_group_config\!/a \ \ \ \ {{name}} => true," "$D/lint_group.rs"+ just format+++ # Print affixes and their descriptions from affixes.json+ printaffixes:+ #! /usr/bin/env node+ Object.entries(+ require('{{justfile_directory()}}/harper-core/affixes.json').affixes+ ).forEach(([affix, fields]) => {+ const description = fields['#'] || '';+ description && console.log(affix + ': ' + description);+ });