Skip to content

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

feat: be good in sth. → be good at sth. (#2368)

Andrew Dunbar552aa079452a
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index 2b1dec9d6..18d6d0256 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -41307,6 +41307,7 @@ realization/~NgS<@
realize/~VdSGBU<@
realized/~VU<@
reallocation/NwgS
+really/R%
realm/~NgS
realness/Nmg
realpolitik/Nmg
@@ -45283,7 +45284,7 @@ snuggest/Ju
snugging/V6
snuggle/NgSVGd
snugness/Ng
-so/~CRJI # removed marginal noun sense
+so/~CR%JI # removed marginal noun sense
soak/VdGSNgz
soaking/~V6NgJ
soap/~NwgSVdG
diff --git a/harper-core/src/expr/sequence_expr.rs b/harper-core/src/expr/sequence_expr.rs
index cdfd9236e..9a5be1c13 100644
--- a/harper-core/src/expr/sequence_expr.rs
+++ b/harper-core/src/expr/sequence_expr.rs
@@ -532,6 +532,7 @@ impl SequenceExpr {
gen_then_from_is!(adverb);
gen_then_from_is!(frequency_adverb);
+ gen_then_from_is!(degree_adverb);
// Determiners
diff --git a/harper-core/src/linting/good_at.rs b/harper-core/src/linting/good_at.rs
new file mode 100644
index 000000000..69ec34648
--- /dev/null
+++ b/harper-core/src/linting/good_at.rs
@@ -0,0 +1,234 @@
+use crate::{
+ Lint, Token,
+ expr::{Expr, FirstMatchOf, SequenceExpr},
+ linting::{ExprLinter, LintKind, Suggestion, expr_linter::Chunk},
+ patterns::{InflectionOfBe, WordSet},
+};
+
+pub struct GoodAt {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for GoodAt {
+ fn default() -> Self {
+ let we_re_not_always_very_good_in_sth = SequenceExpr::default()
+ .then_any_of(vec![
+ Box::new(InflectionOfBe::default()),
+ Box::new(WordSet::new(&[
+ "I'm", "we're", "you're", "he's", "she's", "it's", "they're", "Im", "were",
+ "youre", "your", "hes", "shes", "its", "theyre",
+ ])),
+ ])
+ .t_ws()
+ .then_optional(SequenceExpr::aco("not").t_ws())
+ .then_optional(SequenceExpr::default().then_frequency_adverb().t_ws())
+ .then_optional(SequenceExpr::default().then_degree_adverb().t_ws())
+ .then_word_set(&["good", "bad", "great", "okay", "OK"])
+ .t_ws()
+ .t_aco("in")
+ .t_ws()
+ .then_any_word();
+
+ let good_in_skill_or_subject =
+ SequenceExpr::word_set(&["good", "bad", "great", "okay", "OK"])
+ .t_ws()
+ .t_aco("in")
+ .t_ws()
+ .then_word_set(&[
+ // sciences
+ "biology",
+ "chemistry",
+ "math",
+ "mathematics",
+ "physics",
+ // programming
+ "programming",
+ "coding",
+ "c", // Note: C++ would be multiple tokens
+ "debugging",
+ "go",
+ "java",
+ "javascript",
+ "laravel",
+ "python",
+ "ruby",
+ // languages
+ "english",
+ "chinese",
+ "french",
+ "german",
+ "japanese",
+ "spanish",
+ ]);
+
+ let expr = FirstMatchOf::new(vec![
+ Box::new(we_re_not_always_very_good_in_sth),
+ Box::new(good_in_skill_or_subject),
+ ]);
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for GoodAt {
+ type Unit = Chunk;
+
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, toks: &[Token], src: &[char]) -> Option<Lint> {
+ let prep_idx = toks.len() - 3;
+ let prep_tok = &toks[prep_idx];
+ let prep_span = prep_tok.span;
+
+ Some(Lint {
+ span: prep_span,
+ lint_kind: LintKind::Usage,
+ suggestions: vec![Suggestion::replace_with_match_case(
+ "at".chars().collect(),
+ prep_span.get_content(src),
+ )],
+ message: "Use 'good at' to describe proficiency with a skill.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &'static str {
+ "Checks for `good in` used instead of `good at` to describe proficiency with a skill."
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::GoodAt;
+ use crate::linting::tests::assert_suggestion_result;
+
+ #[test]
+ fn fix_good_in_being_frugal() {
+ assert_suggestion_result(
+ "but we found that Claude is not always very good in being frugal ( Gemini seemed better at it ) .",
+ GoodAt::default(),
+ "but we found that Claude is not always very good at being frugal ( Gemini seemed better at it ) .",
+ );
+ }
+
+ #[test]
+ fn fix_im_not_good_in_python() {
+ assert_suggestion_result(
+ "can't run it i'm not good in python",
+ GoodAt::default(),
+ "can't run it i'm not good at python",
+ );
+ }
+
+ #[test]
+ fn fix_not_good_in_go() {
+ assert_suggestion_result(
+ "Hi, I have very similar problem and I'm not good in go either.",
+ GoodAt::default(),
+ "Hi, I have very similar problem and I'm not good at go either.",
+ );
+ }
+
+ #[test]
+ fn fix_not_good_in_coding_stuff() {
+ assert_suggestion_result(
+ "Unfortunately I can't help in anyway but testing, because I'm not good in coding stuff.",
+ GoodAt::default(),
+ "Unfortunately I can't help in anyway but testing, because I'm not good at coding stuff.",
+ );
+ }
+
+ #[test]
+ fn fix_very_good_in_mathematics() {
+ assert_suggestion_result(
+ "They were very good in Mathematics and were the pets of Ranjani Ma'am.",
+ GoodAt::default(),
+ "They were very good at Mathematics and were the pets of Ranjani Ma'am.",
+ );
+ }
+
+ #[test]
+ fn fix_not_good_in_coding() {
+ assert_suggestion_result(
+ "Didnt know these things.. and since im not good in coding, maybe one day someone will work on this.",
+ GoodAt::default(),
+ "Didnt know these things.. and since im not good at coding, maybe one day someone will work on this.",
+ );
+ }
+
+ #[test]
+ fn fix_very_good_in_most_things() {
+ assert_suggestion_result(
+ "But I do want to continue using riverpod because its very good in most things I need from my app.",
+ GoodAt::default(),
+ "But I do want to continue using riverpod because its very good at most things I need from my app.",
+ );
+ }
+
+ #[test]
+ fn fix_not_good_in_laravel() {
+ assert_suggestion_result(
+ "im not good in laravel.",
+ GoodAt::default(),
+ "im not good at laravel.",
+ );
+ }
+
+ #[test]
+ fn fixim_not_good_in_english() {
+ assert_suggestion_result(
+ "Sorry about my grammar im not good in English.",
+ GoodAt::default(),
+ "Sorry about my grammar im not good at English.",
+ );
+ }
+
+ #[test]
+ fn fix_not_all_good_in_english() {
+ assert_suggestion_result(
+ "I think if there is translation support will be great, our school society not all good in english.",
+ GoodAt::default(),
+ "I think if there is translation support will be great, our school society not all good at english.",
+ );
+ }
+
+ #[test]
+ fn fix_i_am_not_good_in_english() {
+ assert_suggestion_result(
+ "I am in Togo, i am not good in english but i will ask you to apologize me for my speaking.",
+ GoodAt::default(),
+ "I am in Togo, i am not good at english but i will ask you to apologize me for my speaking.",
+ );
+ }
+
+ #[test]
+ fn fix_not_good_in_programming() {
+ assert_suggestion_result(
+ "Is it My Drive,Chess or \"My Drive\",\"Chess\" or what? Because I'm not good in programming.",
+ GoodAt::default(),
+ "Is it My Drive,Chess or \"My Drive\",\"Chess\" or what? Because I'm not good at programming.",
+ );
+ }
+
+ #[test]
+ fn fix_not_so_good_in_coding() {
+ assert_suggestion_result(
+ "I'm not so good in coding to understand how to handle all these bytes...",
+ GoodAt::default(),
+ "I'm not so good at coding to understand how to handle all these bytes...",
+ );
+ }
+
+ #[test]
+ fn fix_im_not_good_in_programming() {
+ assert_suggestion_result(
+ "Im not good in programming , but can i ask what is the password of your codes?",
+ GoodAt::default(),
+ "Im not good at programming , but can i ask what is the password of your codes?",
+ );
+ }
+}
diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rs
index 086aa2325..5f9949048 100644
--- a/harper-core/src/linting/lint_group.rs
+++ b/harper-core/src/linting/lint_group.rs
@@ -73,6 +73,7 @@ use super::for_noun::ForNoun;
use super::free_predicate::FreePredicate;
use super::friend_of_me::FriendOfMe;
use super::go_so_far_as_to::GoSoFarAsTo;
+use super::good_at::GoodAt;
use super::have_pronoun::HavePronoun;
use super::have_take_a_look::HaveTakeALook;
use super::hedging::Hedging;
@@ -549,6 +550,7 @@ impl LintGroup {
insert_expr_rule!(FreePredicate, true);
insert_expr_rule!(FriendOfMe, true);
insert_expr_rule!(GoSoFarAsTo, true);
+ insert_expr_rule!(GoodAt, true);
insert_expr_rule!(HavePronoun, true);
insert_expr_rule!(Hedging, true);
insert_expr_rule!(HelloGreeting, true);
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index d289f498b..673f3c5ba 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -68,6 +68,7 @@ mod for_noun;
mod free_predicate;
mod friend_of_me;
mod go_so_far_as_to;
+mod good_at;
mod handful;
mod have_pronoun;
mod have_take_a_look;