Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

fix: don't make compounds with conjunctions (#1735)

Andrew Dunbar3d6a6a5b04ae
diff --git a/harper-core/src/linting/compound_nouns/mod.rs b/harper-core/src/linting/compound_nouns/mod.rs
index 46a099e1e..e1a0a0e3e 100644
--- a/harper-core/src/linting/compound_nouns/mod.rs
+++ b/harper-core/src/linting/compound_nouns/mod.rs
@@ -13,8 +13,8 @@ pub(crate) fn is_content_word(tok: &Token, src: &[char]) -> bool {
tok.span.len() > 1
&& (meta.is_noun() || meta.is_adjective() || meta.is_verb() || meta.is_adverb())
- && !meta.is_determiner()
- && (!meta.preposition || *tok.span.get_content(src).to_lower() == ['b', 'a', 'r'])
+ && !(meta.is_determiner() || meta.is_conjunction())
+ && (!meta.preposition || tok.span.get_content(src).eq_ignore_ascii_case_str("bar"))
}
pub(crate) fn predicate(closed: Option<&WordMetadata>, open: Option<&WordMetadata>) -> bool {
@@ -385,4 +385,12 @@ mod tests {
CompoundNouns::default(),
);
}
+
+ #[test]
+ fn dont_flag_project_or() {
+ assert_no_lints(
+ "You can star or watch this project or follow author to get release notifications in time.",
+ CompoundNouns::default(),
+ );
+ }
}
diff --git a/harper-core/tests/text/linters/The Constitution of the United States.snap.yml b/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
index f6ab709c5..255b04460 100644
--- a/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
+++ b/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
@@ -1593,16 +1593,6 @@ Message: |
-Lint: WordChoice (63 priority)
-Message: |
- 658 | questioned. But neither the United States nor any State shall assume or pay any
- 659 | debt or obligation incurred in aid of insurrection or rebellion against the
- | ^~~~~~~ Did you mean the closed compound noun “debtor”?
-Suggest:
- - Replace with: “debtor”
-
-
-
Lint: Spelling (63 priority)
Message: |
663 | ## Article. V.