Skip to content

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

fix(core): use tagger to improve certainty in `HowTo` lint (#1489)

Elijah Potter52db2b746b17
diff --git a/harper-core/src/linting/how_to.rs b/harper-core/src/linting/how_to.rs
index 807ef2439..65e5a1500 100644
--- a/harper-core/src/linting/how_to.rs
+++ b/harper-core/src/linting/how_to.rs
@@ -1,3 +1,5 @@
+use harper_brill::UPOS;
+
use crate::expr::All;
use crate::expr::Expr;
use crate::expr::OwnedExprExt;
@@ -16,10 +18,12 @@ impl Default for HowTo {
fn default() -> Self {
let mut pattern = All::default();
- let pos_pattern = SequenceExpr::default()
- .t_aco("how")
- .then_whitespace()
- .then_verb();
+ let pos_pattern = SequenceExpr::default().t_aco("how").then_whitespace().then(
+ |tok: &Token, _: &[char]| {
+ tok.kind.is_upos(UPOS::VERB)
+ || (tok.kind.is_verb() && tok.kind.is_likely_homograph())
+ },
+ );
pattern.add(pos_pattern);
let exceptions = SequenceExpr::default()
@@ -256,4 +260,9 @@ mod tests {
0,
);
}
+
+ #[test]
+ fn allows_how_has() {
+ assert_lint_count("How Has This Been Tested?", HowTo::default(), 0);
+ }
}