Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(core): restrict rule to auxiliary verbs
Elijah Potterb54befaaf69f
diff --git a/harper-core/affixes.json b/harper-core/affixes.jsonindex ab65899c1..85b01c0fe 100644--- a/harper-core/affixes.json+++ b/harper-core/affixes.json@@ -645,6 +645,18 @@"gifts_metadata": {"adverb": {}}+ },+ "m": {+ "#": "auxiliary verb property",+ "suffix": true,+ "cross_product": true,+ "replacements": [],+ "adds_metadata": {},+ "gifts_metadata": {+ "verb": {+ "is_auxiliary": true+ }+ }}}}diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dictindex 12f1d602b..f92a6b4e1 100644--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@ -13636,7 +13636,7 @@ bazillion/1Sbazooka/14SMbbl/1bdrm/1-be/41~+be/m1~beach/14MDSGbeachcomber/1SMbeachfront/51@@ -13946,7 +13946,7 @@ bespeak/41SGbespectacled/5bespoke/54bespoken/45-best/514SGMD+best/51mSGMDbestial/51Ybestiality/1Mbestiary/1SM@@ -13981,7 +13981,7 @@ betroth/4DGbetrothal/1SMbetrothed/451Mbetroths/4-better/514MDGLS+better/51mMDGLSbetterment/1Mbetting/541bettor/1MS@@ -15645,8 +15645,8 @@ campsite/1SMcampus/14MScampy/5TRcamshaft/1SM-can't/4-can/41SMDRZG+can't/m+can/m1SMDRZGcanal/14MScanalization/1Mcanalize/4GDS@@ -17276,7 +17276,7 @@ coerce/4DRSZGNVcoercer/1Mcoercion/1Mcoeval/51SMY-coexist/4DSG+coexist/4DGcoexistence/1Mcoexistent/51coextensive/5@@ -18523,7 +18523,7 @@ couchette/1Scougar/1SMcough/41MDGcoughs/14-could/41~+could/m1~could've/4couldn't/4coulee/1SM@@ -19377,7 +19377,7 @@ dankness/1Mdanseuse/1MSdapper/5TRdapple/154MGDS-dare/41DRSMZG+dare/m1DRSMZGdaredevil/154MSdaredevilry/1Mdarer/1M@@ -20707,7 +20707,7 @@ dizzily/dizziness/1Mdizzy/541DRSPTGdjellaba/1MS-do/41SJMRHZG~+do/m1SJMRHZG~doable/51dob/41Sdobbed/4@@ -26399,7 +26399,7 @@ haunt/41SMDRZGhaunter/1Mhaunting/451Yhauteur/1M-have/41MGS~+have/m1MGS~haven't/4haven/14SMhaversack/1SM@@ -31576,7 +31576,7 @@ maximal/51Ymaximization/1Mmaximize/4GDSmaximum/15SM-may/41M+may/m1Mmaybe/5j1SMmayday/1MSmayflower/1MS@@ -32071,10 +32071,10 @@ midyear/1MSmien/1Mmiff/14DSGmight've/4-might/154M+might/15mMmightily/mightiness/1M-mightn't/4+mightn't/mmighty/15TRPmignonette/15SMmigraine/1MS@@ -33347,7 +33347,7 @@ necrotic/5nectar/14Mnectarine/15MSnee/5-need/14MDSG~+need/1mMDSG~needed/54Uneedful/51Yneediness/1M@@ -33358,7 +33358,7 @@ needlessness/1Mneedlewoman/1Mneedlewomen/9needlework/1M-needn't/4+needn't/mneedy/5PTRnefarious/5YPnefariousness/1M@@ -34793,8 +34793,8 @@ otter/1MSottoman/1MSoubliette/1MSouch/14-ought/481-oughtn't/4+ought/m81+oughtn't/mounce/1MSour/4S~ourselves/8@@ -41545,7 +41545,7 @@ shakily/shakiness/1Mshaky/5RPTshale/14M-shall/4+shall/mshallot/1MSshallow/514TPMRYSshallowness/1M@@ -41813,7 +41813,7 @@ shot/514MSshotgun/14SMshotgunned/4shotgunning/4-should/4+should/mshould've/4shoulder/14MDGSshouldn't/41@@ -48985,7 +48985,7 @@ wildness/1Mwilds/14Mwile/14MGDSwiliness/1M-will/41MDS~+will/m1MDS~willful/5PYwillfulness/1Mwillies/1M@@ -49331,8 +49331,8 @@ worthy/514UPRTwot/48wotcha/would've/-would/41S~-wouldn't/4+would/m1S~+wouldn't/mwouldst/4wound/14SGMDRwove/45A@@ -50038,3 +50038,4 @@ GLFW/2MChatGPT/2Mamidst/+reimagined/4+coexists/4diff --git a/harper-core/src/linting/compound_nouns/implied_action_compound_nouns.rs b/harper-core/src/linting/compound_nouns/implied_instantiated_compound_nouns.rssimilarity index 80%rename from harper-core/src/linting/compound_nouns/implied_action_compound_nouns.rsrename to harper-core/src/linting/compound_nouns/implied_instantiated_compound_nouns.rsindex 4183cdded..f88745b41 100644--- a/harper-core/src/linting/compound_nouns/implied_action_compound_nouns.rs+++ b/harper-core/src/linting/compound_nouns/implied_instantiated_compound_nouns.rs@@ -9,14 +9,12 @@ use crate::{patterns::{Pattern, SequencePattern},};-/// Looks for closed compound nouns which can be condensed due to their position after a-/// possessive noun (which implies ownership).-pub struct ImpliedActionCompoundNouns {+pub struct ImpliedInstantiatedCompoundNouns {pattern: Box<dyn Pattern>,split_pattern: Lrc<SplitCompoundWord>,}-impl Default for ImpliedActionCompoundNouns {+impl Default for ImpliedInstantiatedCompoundNouns {fn default() -> Self {let split_pattern = Lrc::new(SplitCompoundWord::new(|meta| {meta.is_noun() && !meta.is_proper_noun()@@ -24,9 +22,7 @@ impl Default for ImpliedActionCompoundNouns {let pattern = SequencePattern::default().then(split_pattern.clone()).then_whitespace()- .then(|tok: &Token, _source: &[char]| {- tok.kind.is_verb() && !tok.kind.is_likely_homograph()- });+ .then(|tok: &Token, _source: &[char]| tok.kind.is_auxiliary_verb());Self {pattern: Box::new(pattern),@@ -35,7 +31,7 @@ impl Default for ImpliedActionCompoundNouns {}}-impl PatternLinter for ImpliedActionCompoundNouns {+impl PatternLinter for ImpliedInstantiatedCompoundNouns {fn pattern(&self) -> &dyn Pattern {self.pattern.as_ref()}diff --git a/harper-core/src/linting/compound_nouns/mod.rs b/harper-core/src/linting/compound_nouns/mod.rsindex d7b0b3e8f..466cb608c 100644--- a/harper-core/src/linting/compound_nouns/mod.rs+++ b/harper-core/src/linting/compound_nouns/mod.rs@@ -1,14 +1,14 @@mod general_compound_nouns;-mod implied_action_compound_nouns;+mod implied_instantiated_compound_nouns;mod implied_ownership_compound_nouns;use super::{Lint, LintKind, Suggestion, merge_linters::merge_linters};use general_compound_nouns::GeneralCompoundNouns;-use implied_action_compound_nouns::ImpliedActionCompoundNouns;+use implied_instantiated_compound_nouns::ImpliedInstantiatedCompoundNouns;use implied_ownership_compound_nouns::ImpliedOwnershipCompoundNouns;-merge_linters!(CompoundNouns => GeneralCompoundNouns, ImpliedOwnershipCompoundNouns, ImpliedActionCompoundNouns => "Detects compound nouns split by a space and suggests merging them when both parts form a valid noun." );+merge_linters!(CompoundNouns => GeneralCompoundNouns, ImpliedInstantiatedCompoundNouns, ImpliedOwnershipCompoundNouns => "Detects compound nouns split by a space and suggests merging them when both parts form a valid noun." );#[cfg(test)]mod tests {@@ -293,4 +293,13 @@ mod tests {0,);}++ #[test]+ fn allow_suppress_or() {+ assert_lint_count(+ "He must decide whether to suppress or coexist with his doppelgänger.",+ CompoundNouns::default(),+ 0,+ );+ }}diff --git a/harper-core/src/token_kind.rs b/harper-core/src/token_kind.rsindex b5d593cfe..3f1818a52 100644--- a/harper-core/src/token_kind.rs+++ b/harper-core/src/token_kind.rs@@ -259,6 +259,14 @@ impl TokenKind {metadata.is_verb()}+ pub fn is_auxiliary_verb(&self) -> bool {+ let TokenKind::Word(Some(metadata)) = self else {+ return false;+ };++ metadata.is_auxiliary_verb()+ }+pub fn is_linking_verb(&self) -> bool {let TokenKind::Word(Some(metadata)) = self else {return false;diff --git a/harper-core/src/word_metadata.rs b/harper-core/src/word_metadata.rsindex 24503c14a..8922a17be 100644--- a/harper-core/src/word_metadata.rs+++ b/harper-core/src/word_metadata.rs@@ -103,7 +103,7 @@ impl WordMetadata {generate_metadata_queries!(noun has proper, plural, possessive, pronoun.- verb has linking.+ verb has linking, auxiliary.conjunction has.adjective has.adverb has@@ -131,6 +131,7 @@ pub enum Tense {#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Hash, Default)]pub struct VerbData {pub is_linking: Option<bool>,+ pub is_auxiliary: Option<bool>,pub tense: Option<Tense>,}@@ -139,6 +140,7 @@ impl VerbData {pub fn or(&self, other: &Self) -> Self {Self {is_linking: self.is_linking.or(other.is_linking),+ is_auxiliary: self.is_auxiliary.or(other.is_auxiliary),tense: self.tense.or(other.tense),}}