Skip to content

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

Fix FindFine false positive on 'is find <noun>' (#3363)

Sai Asish Y5193a7575ab6
diff --git a/harper-core/src/linting/find_fine.rs b/harper-core/src/linting/find_fine.rs
index 1b3a4f47b..81224ba35 100644
--- a/harper-core/src/linting/find_fine.rs
+++ b/harper-core/src/linting/find_fine.rs
@@ -1,7 +1,10 @@
+use harper_brill::UPOS;
+
use crate::Token;
use crate::expr::Expr;
use crate::expr::SequenceExpr;
use crate::patterns::InflectionOfBe;
+use crate::patterns::UPOSSet;
use super::expr_linter::Chunk;
use super::{ExprLinter, Lint, LintKind, Suggestion};
@@ -14,7 +17,15 @@ impl Default for FindFine {
fn default() -> Self {
let expr = SequenceExpr::with(InflectionOfBe::default())
.t_ws()
- .t_aco("find");
+ .t_aco("find")
+ // Don't flag when `find` is followed by something that could be its
+ // object, e.g. "what you want to do is find someone to replace you".
+ .then_unless(SequenceExpr::whitespace().then(UPOSSet::new(&[
+ UPOS::NOUN,
+ UPOS::PROPN,
+ UPOS::PRON,
+ UPOS::DET,
+ ])));
Self { expr }
}
@@ -49,7 +60,7 @@ impl ExprLinter for FindFine {
#[cfg(test)]
mod tests {
- use crate::linting::tests::assert_suggestion_result;
+ use crate::linting::tests::{assert_lint_count, assert_suggestion_result};
use super::FindFine;
@@ -71,4 +82,13 @@ mod tests {
"I am fine not using GPU at all for open3d.",
);
}
+
+ #[test]
+ fn dont_flag_is_find_someone_3255() {
+ assert_lint_count(
+ "Generally speaking what you want to try and do is find someone to replace you before you leave.",
+ FindFine::default(),
+ 0,
+ );
+ }
}