Skip to content

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.json
index 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.dict
index 12f1d602b..f92a6b4e1 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -13636,7 +13636,7 @@ bazillion/1S
bazooka/14SM
bbl/1
bdrm/1
-be/41~
+be/m1~
beach/14MDSG
beachcomber/1SM
beachfront/51
@@ -13946,7 +13946,7 @@ bespeak/41SG
bespectacled/5
bespoke/54
bespoken/45
-best/514SGMD
+best/51mSGMD
bestial/51Y
bestiality/1M
bestiary/1SM
@@ -13981,7 +13981,7 @@ betroth/4DG
betrothal/1SM
betrothed/451M
betroths/4
-better/514MDGLS
+better/51mMDGLS
betterment/1M
betting/541
bettor/1MS
@@ -15645,8 +15645,8 @@ campsite/1SM
campus/14MS
campy/5TR
camshaft/1SM
-can't/4
-can/41SMDRZG
+can't/m
+can/m1SMDRZG
canal/14MS
canalization/1M
canalize/4GDS
@@ -17276,7 +17276,7 @@ coerce/4DRSZGNV
coercer/1M
coercion/1M
coeval/51SMY
-coexist/4DSG
+coexist/4DG
coexistence/1M
coexistent/51
coextensive/5
@@ -18523,7 +18523,7 @@ couchette/1S
cougar/1SM
cough/41MDG
coughs/14
-could/41~
+could/m1~
could've/4
couldn't/4
coulee/1SM
@@ -19377,7 +19377,7 @@ dankness/1M
danseuse/1MS
dapper/5TR
dapple/154MGDS
-dare/41DRSMZG
+dare/m1DRSMZG
daredevil/154MS
daredevilry/1M
darer/1M
@@ -20707,7 +20707,7 @@ dizzily/
dizziness/1M
dizzy/541DRSPTG
djellaba/1MS
-do/41SJMRHZG~
+do/m1SJMRHZG~
doable/51
dob/41S
dobbed/4
@@ -26399,7 +26399,7 @@ haunt/41SMDRZG
haunter/1M
haunting/451Y
hauteur/1M
-have/41MGS~
+have/m1MGS~
haven't/4
haven/14SM
haversack/1SM
@@ -31576,7 +31576,7 @@ maximal/51Y
maximization/1M
maximize/4GDS
maximum/15SM
-may/41M
+may/m1M
maybe/5j1SM
mayday/1MS
mayflower/1MS
@@ -32071,10 +32071,10 @@ midyear/1MS
mien/1M
miff/14DSG
might've/4
-might/154M
+might/15mM
mightily/
mightiness/1M
-mightn't/4
+mightn't/m
mighty/15TRP
mignonette/15SM
migraine/1MS
@@ -33347,7 +33347,7 @@ necrotic/5
nectar/14M
nectarine/15MS
nee/5
-need/14MDSG~
+need/1mMDSG~
needed/54U
needful/51Y
neediness/1M
@@ -33358,7 +33358,7 @@ needlessness/1M
needlewoman/1M
needlewomen/9
needlework/1M
-needn't/4
+needn't/m
needy/5PTR
nefarious/5YP
nefariousness/1M
@@ -34793,8 +34793,8 @@ otter/1MS
ottoman/1MS
oubliette/1MS
ouch/14
-ought/481
-oughtn't/4
+ought/m81
+oughtn't/m
ounce/1MS
our/4S~
ourselves/8
@@ -41545,7 +41545,7 @@ shakily/
shakiness/1M
shaky/5RPT
shale/14M
-shall/4
+shall/m
shallot/1MS
shallow/514TPMRYS
shallowness/1M
@@ -41813,7 +41813,7 @@ shot/514MS
shotgun/14SM
shotgunned/4
shotgunning/4
-should/4
+should/m
should've/4
shoulder/14MDGS
shouldn't/41
@@ -48985,7 +48985,7 @@ wildness/1M
wilds/14M
wile/14MGDS
wiliness/1M
-will/41MDS~
+will/m1MDS~
willful/5PY
willfulness/1M
willies/1M
@@ -49331,8 +49331,8 @@ worthy/514UPRT
wot/48
wotcha/
would've/
-would/41S~
-wouldn't/4
+would/m1S~
+wouldn't/m
wouldst/4
wound/14SGMDR
wove/45A
@@ -50038,3 +50038,4 @@ GLFW/2M
ChatGPT/2M
amidst/+
reimagined/4
+coexists/4
diff --git a/harper-core/src/linting/compound_nouns/implied_action_compound_nouns.rs b/harper-core/src/linting/compound_nouns/implied_instantiated_compound_nouns.rs
similarity index 80%
rename from harper-core/src/linting/compound_nouns/implied_action_compound_nouns.rs
rename to harper-core/src/linting/compound_nouns/implied_instantiated_compound_nouns.rs
index 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.rs
index 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.rs
index 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.rs
index 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),
}
}