Skip to content

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

feat: correct "dose" as typo for "does" (#1637)

Andrew Dunbar748e308bb498
diff --git a/harper-core/src/linting/phrase_set_corrections/mod.rs b/harper-core/src/linting/phrase_set_corrections/mod.rs
index 230a38451..2f07f2fb8 100644
--- a/harper-core/src/linting/phrase_set_corrections/mod.rs
+++ b/harper-core/src/linting/phrase_set_corrections/mod.rs
@@ -115,6 +115,26 @@ pub fn lint_group() -> LintGroup {
// or maybe Redundancy?
LintKind::Usage
),
+ "DoesOrDose" => (
+ &[
+ // Negatives
+ ("dose not", "does not"),
+ // Pronouns
+ ("he dose", "he does"),
+ ("it dose", "it does"),
+ ("she dose", "she does"),
+ ("someone dose", "someone does"),
+ // Interrogatives
+ ("how dose", "how does"),
+ ("when dose", "when does"),
+ ("where dose", "where does"),
+ ("who dose", "who does"),
+ ("why dose", "why does"),
+ ],
+ "This may be a typo for `does`.",
+ "Tries to correct typos of `dose` to `does`.",
+ LintKind::Typo
+ ),
"ExpandArgument" => (
&[
("arg", "argument"),
diff --git a/harper-core/src/linting/phrase_set_corrections/tests.rs b/harper-core/src/linting/phrase_set_corrections/tests.rs
index a320774de..d55d36d69 100644
--- a/harper-core/src/linting/phrase_set_corrections/tests.rs
+++ b/harper-core/src/linting/phrase_set_corrections/tests.rs
@@ -166,6 +166,223 @@ fn corrects_definite_articles_lowercase() {
// Discuss
// -none-
+// DoesOrDose
+
+// -does not-
+#[test]
+fn corrects_dose_not() {
+ assert_suggestion_result(
+ "It dose not run windows ?",
+ lint_group(),
+ "It does not run windows ?",
+ );
+}
+
+// -dose it true positive-
+#[test]
+#[ignore = "due to false positives this can't be fixed yet"]
+fn corrects_dose_it() {
+ assert_suggestion_result(
+ "dose it support zh_cn ?",
+ lint_group(),
+ "does it support zh_cn ?",
+ );
+}
+
+// -dose it- noun false positives
+
+// it should be noted that (in an excessive dose) (it might have an opposite effect)
+#[test]
+#[ignore = "would be a false positive in a naive implementation"]
+fn dont_flag_excessive_dose_it_might() {
+ assert_lint_count(
+ "it should be noted that in an excessive dose it might have an opposite effect",
+ lint_group(),
+ 0,
+ );
+}
+
+// When the person receives (a prescribed second dose) (it is not counted ttwice)
+#[test]
+#[ignore = "would be a false positive in a naive implementation"]
+fn dont_flag_second_dose_it_is_not() {
+ assert_lint_count(
+ "When the person receives a prescribed second dose it is not counted ttwice",
+ lint_group(),
+ 0,
+ );
+}
+
+// (At that small a dose) (it was pleasent).
+#[test]
+#[ignore = "would be a false positive in a naive implementation"]
+fn dont_flag_a_dose_it_was() {
+ assert_lint_count("At that small a dose it was pleasent.", lint_group(), 0);
+}
+
+// I do not know (what dose) (it takes) to trip out, but I don't think I could stay awake to find out.
+#[test]
+#[ignore = "would be a false positive in a naive implementation"]
+fn dont_flag_what_dose_it_takes() {
+ assert_lint_count(
+ "I do not know what dose it takes to trip out, but I don't think I could stay awake to find out.",
+ lint_group(),
+ 0,
+ );
+}
+
+// -dose it- verb false positives
+
+// And then I have to re-add the salts back to it to dose it back up to drinkable.
+#[test]
+#[ignore = "would be a false positive in a naive implementation"]
+fn dont_flag_to_dose_it() {
+ assert_lint_count(
+ "And then I have to re-add the salts back to it to dose it back up to drinkable.",
+ lint_group(),
+ 0,
+ );
+}
+
+// So my conclusion is: don't dose it too high or it actually is dangerous and not pleasant at all
+#[test]
+#[ignore = "would be a false positive in a naive implementation"]
+fn dont_flag_dont_dose_it_too_high() {
+ assert_lint_count(
+ "So my conclusion is: don't dose it too high or it actually is dangerous and not pleasant at all",
+ lint_group(),
+ 0,
+ );
+}
+
+// the only solution the other hopefully-dominant-reasonable-adult-human mind can find, is to dose it off, hoping the drowsiness can keep the fear at bay
+#[test]
+#[ignore = "would be a false positive in a naive implementation"]
+fn dont_flag_to_dose_it_off() {
+ assert_lint_count(
+ "the only solution the other hopefully-dominant-reasonable-adult-human mind can find, is to dose it off, hoping the drowsiness can keep the fear at bay",
+ lint_group(),
+ 0,
+ );
+}
+
+// -he/she/it does-
+#[test]
+fn corrects_he_does() {
+ assert_suggestion_result(
+ "This validate each and every field of your from with nice dotted red color warring for the user, incase he dose some mistakes.",
+ lint_group(),
+ "This validate each and every field of your from with nice dotted red color warring for the user, incase he does some mistakes.",
+ );
+}
+
+#[test]
+fn corrects_she_does() {
+ assert_suggestion_result(
+ "we wont agree on everything she dose thats what a real person would feel like",
+ lint_group(),
+ "we wont agree on everything she does thats what a real person would feel like",
+ );
+}
+
+// -it does-
+#[test]
+fn corrects_it_dose() {
+ assert_suggestion_result(
+ "it dose work without WEBP enabled",
+ lint_group(),
+ "it does work without WEBP enabled",
+ );
+}
+
+// -someone does-
+#[test]
+fn corrects_someone_dose() {
+ assert_suggestion_result(
+ "Hopefully someone dose, I'm not good at C programing....",
+ lint_group(),
+ "Hopefully someone does, I'm not good at C programing....",
+ );
+}
+
+// -interrogatives-
+#[test]
+fn corrects_how_dose() {
+ assert_suggestion_result(
+ "How dose qsv-copy works?",
+ lint_group(),
+ "How does qsv-copy works?",
+ );
+}
+
+#[test]
+#[ignore = "false positive not yet detected"]
+fn dont_fix_how_dose_false_positive() {
+ assert_lint_count(
+ "Work in progress exploration of how dose modifications throughout a trial can also induce bias in the exposure-response relationships.",
+ lint_group(),
+ 0,
+ );
+}
+
+#[test]
+fn corrects_when_dose() {
+ assert_suggestion_result(
+ "When dose reusebale variable sync between device? #2634",
+ lint_group(),
+ "When does reusebale variable sync between device? #2634",
+ );
+}
+
+#[test]
+#[ignore = "false positive not yet detected"]
+fn dont_fix_when_dose_false_positive() {
+ assert_lint_count(
+ "Should we remove the dose when dose has been applied",
+ lint_group(),
+ 0,
+ );
+}
+
+#[test]
+fn corrects_where_dose() {
+ assert_suggestion_result(
+ "where dose the password store?",
+ lint_group(),
+ "where does the password store?",
+ );
+}
+
+#[test]
+#[ignore = "false positive not yet detected"]
+fn dont_fix_where_dose_false_positive() {
+ assert_lint_count(
+ "added some better error handling for the weird case where dose files have no dose...",
+ lint_group(),
+ 0,
+ );
+}
+
+#[test]
+fn corrects_who_dose() {
+ assert_suggestion_result(
+ "Who dose knows the problem?",
+ lint_group(),
+ "Who does knows the problem?",
+ );
+}
+
+#[test]
+fn corrects_why_dose() {
+ assert_suggestion_result(
+ "why dose the path is random ?",
+ lint_group(),
+ "why does the path is random ?",
+ );
+}
+
+// Note: no false positive detected for 'why does'. Only true positives.
+
// ExpandDependency
// -none-