Skip to content

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

Merge branch 'master' of https://github.com/Automattic/harper into whole-entire

hippietrailb559a3769816
diff --cc harper-core/src/linting/phrase_corrections.rs
index 453f0805e,7e6943368..92a6dd59d
--- a/harper-core/src/linting/phrase_corrections.rs
+++ b/harper-core/src/linting/phrase_corrections.rs
@@@ -615,19 -649,108 +649,121 @@@ pub fn lint_group() -> LintGroup
"Use `nerve-racking` for something that causes anxiety or tension.",
"Corrects common misspellings and missing hyphen in `nerve-racking`."
),
- "WholeEntire" => (
- ["whole entire"],
- ["whole", "entire"],
- "Avoid redundancy. Use either `whole` or `entire` for referring to the complete amount or extent.",
- "Corrects the redundancy in `whole entire` to `whole` or `entire`."
- ),
+ // Avoid suggestions resulting in "a entire ...."
+ // "AWholeEntire" => (
+ // ["a whole entire"],
+ // ["a whole", "an entire"],
+ // "Avoid redundancy. Use either `whole` or `entire` for referring to the complete amount or extent.",
+ // "Corrects the redundancy in `whole entire` to `whole` or `entire`."
+ // ),
++ "WholeEntire" => (
++ ["whole entire"],
++ ["whole", "entire"],
++ "Avoid redundancy. Use either `whole` or `entire` for referring to the complete amount or extent.",
++ "Corrects the redundancy in `whole entire` to `whole` or `entire`."
++ ),
+ "InDetail" => (
+ ["in details"],
+ ["in detail"],
+ "Use singular `in detail` for referring to a detailed description.",
+ "Correct unidiomatic plural `in details` to `in detail`."
+ ),
+ "InMoreDetail" => (
+ ["in more details"],
+ ["in more detail"],
+ "Use singular `in more detail` for referring to a detailed description.",
+ "Correct unidiomatic plural `in more details` to `in more detail`."
+ ),
+ "TickingTimeClock" => (
+ ["ticking time clock"],
+ ["ticking time bomb", "ticking clock"],
+ "Use `ticking time bomb` for disastrous consequences, otherwise avoid redundancy with just `ticking clock`.",
+ "Corrects `ticking time clock` to `ticking time bomb` for idiomatic urgency or `ticking clock` otherwise."
+ ),
+ "InAndOfItself" => (
+ ["in of itself"],
+ ["in and of itself"],
+ "Use `in and of itself` for referring to something's inherent or intrinsic quality.",
+ "Corrects nonstandard `in of itself` to standard `in and of itself`."
+ ),
+ "ALotWorst" => (
+ ["a lot worst", "alot worst"],
+ ["a lot worse"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `a lot worst` to `a lot worse` for proper comparative usage."
+ ),
+ "FarWorse" => (
+ ["far worst"],
+ ["far worse"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `far worst` to `far worse` for proper comparative usage."
+ ),
+ "MuchWorse" => (
+ ["much worst"],
+ ["much worse"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `much worst` to `much worse` for proper comparative usage."
+ ),
+ "TurnForTheWorse" => (
+ ["turn for the worst"],
+ ["turn for the worse"],
+ "Use `turn for the worse` for a negative change in circumstances. Avoid the incorrect `turn for the worst`.",
+ "Corrects the nonstandard `turn for the worst` to the idiomatic `turn for the worse`, used to describe a situation that has deteriorated."
+ ),
+ "WorseAndWorse" => (
+ ["worst and worst", "worse and worst", "worst and worse"],
+ ["worse and worse"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `worst and worst` to `worse and worse` for proper comparative usage."
+ ),
+ "WorseThan" => (
+ ["worst than"],
+ ["worse than"],
+ "Use `worse` for comparing. (`Worst` is for the extreme case)",
+ "Corrects `worst than` to `worse than` for proper comparative usage."
+ ),
+ "WorstEver" => (
+ ["worse ever"],
+ ["worst ever"],
+ "Use `worst` for the extreme case. (`Worse` is for comparing)",
+ "Corrects `worse ever` to `worst ever` for proper comparative usage."
+ ),
+ "Monumentous" => (
+ ["monumentous"],
+ ["momentous", "monumental"],
+ "Retain `monumentous` for jocular effect. Otherwise `momentous` indicates great signifcance while `monumental` indicates imposing size.",
+ "Advises using `momentous` or `monumental` instead of `monumentous` for serious usage."
+ ),
+ "InAnyWay" => (
+ ["in anyway"],
+ ["in any way"],
+ "Use `in any way` for emphasizing a point.",
+ "Corrects ungrammatical `in anyway` to `in any way`."
+ ),
+ "ExplanationMark" => (
+ ["explanation mark"],
+ ["exclamation mark"],
+ "The correct name for the `!` punctuation is `exclamation mark`.",
+ "Corrects the eggcorn `explanation mark` to `exclamation mark`."
+ ),
+ "ExplanationMarks" => (
+ ["explanation marks"],
+ ["exclamation marks"],
+ "The correct name for the `!` punctuation is `exclamation mark`.",
+ "Corrects the eggcorn `explanation mark` to `exclamation mark`."
+ ),
+ "ExplanationPoint" => (
+ ["explanation point"],
+ ["exclamation point"],
+ "The correct name for the `!` punctuation is `exclamation point`.",
+ "Corrects the eggcorn `explanation point` to `exclamation point`."
+ ),
+ "AsFarBackAs" => (
+ ["as early back as"],
+ ["as far back as"],
+ "Use `as far back as` for referring to a time in the past.",
+ "Corrects nonstandard `as early back as` to `as far back as`."
+ ),
});
group.set_all_rules_to(Some(true));
@@@ -866,41 -1047,253 +1060,296 @@@ mod tests
}
#[test]
+ fn detect_atomic_whole_entire() {
+ assert_suggestion_result("whole entire", lint_group(), "whole");
+ }
+
- #[test]
- fn correct_atomic_a_whole_entire_to_a_whole() {
- assert_suggestion_result("a whole entire", lint_group(), "a whole");
- }
++ // #[test]
++ // fn correct_atomic_a_whole_entire_to_a_whole() {
++ // assert_suggestion_result("a whole entire", lint_group(), "a whole");
++ // }
+
- // TODO: uncomment with assert_second_suggestion_result arrives via my other PR
+ // #[test]
- // fn correct_atomic_an_whole_entire_to_an_entire() {
- // assert_second_suggestion_result(
- // "an whole entire",
- // lint_group(),
- // "an entire",
- // );
++ // fn correct_a_whole_entire_surrounded_by_text() {
++ // assert_suggestion_result("A B C a whole entire X Y Z", lint_group(), "A B C a whole X Y Z");
+ // }
+
++ #[test]
++ fn correct_atomic_an_whole_entire_to_an_entire() {
++ assert_second_suggestion_result(
++ "an whole entire",
++ lint_group(),
++ "an entire",
++ );
++ }
++
+ #[test]
+ fn correct_real_world_whole_entire() {
+ assert_suggestion_result(
+ "[FR] support use system dns in whole entire app",
+ lint_group(),
+ "[FR] support use system dns in whole app",
+ );
+ }
+
+ // TODO: something goes wrong when both WholeEntire and AWholeEntire are enabled
++ // TODO: result is `Start mapping a wholeanet using NASA’s MOLA.`
+ // #[test]
+ // fn correct_real_world_a_whole_entire() {
+ // assert_suggestion_result(
+ // "Start mapping a whole entire new planet using NASA’s MOLA.",
+ // lint_group(),
+ // "Start mapping a whole new planet using NASA’s MOLA.",
+ // );
+ // }
++
+ fn in_detail_atomic() {
+ assert_suggestion_result("in details", lint_group(), "in detail");
+ }
+
+ #[test]
+ fn in_more_detail_atomic() {
+ assert_suggestion_result("in more details", lint_group(), "in more detail");
+ }
+
+ #[test]
+ fn in_detail_real_world() {
+ assert_suggestion_result(
+ "c++ - who can tell me \"*this pointer\" in details?",
+ lint_group(),
+ "c++ - who can tell me \"*this pointer\" in detail?",
+ )
+ }
+
+ #[test]
+ fn suggests_ticking_time_bomb() {
+ assert_suggestion_result(
+ "One element that can help up the stakes (and tension!) is a “ticking time clock.”",
+ lint_group(),
+ "One element that can help up the stakes (and tension!) is a “ticking time bomb.”",
+ );
+ }
+
+ #[test]
+ fn in_more_detail_real_world() {
+ assert_suggestion_result(
+ "Document the interface in more details · Issue #3 · owlbarn ...",
+ lint_group(),
+ "Document the interface in more detail · Issue #3 · owlbarn ...",
+ );
+ }
+
+ #[test]
+ fn detect_atomic_in_of_itself() {
+ assert_suggestion_result("in of itself", lint_group(), "in and of itself");
+ }
+
+ #[test]
+ fn correct_real_world_in_of_itself() {
+ assert_suggestion_result(
+ "This is not entirely unexpected in of itself, as Git and GitHub Desktop both generally prove fairly bad at delineating context intelligently...",
+ lint_group(),
+ "This is not entirely unexpected in and of itself, as Git and GitHub Desktop both generally prove fairly bad at delineating context intelligently...",
+ )
+ }
+
+ #[test]
+ fn detect_a_lot_worse_atomic() {
+ assert_suggestion_result("a lot worst", lint_group(), "a lot worse");
+ }
+
+ #[test]
+ fn detect_a_lot_worse_real_world() {
+ assert_suggestion_result(
+ "On a debug build, it's even a lot worst.",
+ lint_group(),
+ "On a debug build, it's even a lot worse.",
+ );
+ }
+
+ #[test]
+ fn suggests_ticking_clock() {
+ assert_second_suggestion_result(
+ "The opportunity itself has a ticking time clock as all great opportunities do.",
+ lint_group(),
+ "The opportunity itself has a ticking clock as all great opportunities do.",
+ );
+ }
+
+ #[test]
+ fn detect_far_worse_atomic() {
+ assert_suggestion_result("far worst", lint_group(), "far worse");
+ }
+
+ #[test]
+ fn detect_far_worse_real_world() {
+ assert_suggestion_result(
+ "I mainly use Firefox (personal preference) and have noticed it has far worst performance than Chrome",
+ lint_group(),
+ "I mainly use Firefox (personal preference) and have noticed it has far worse performance than Chrome",
+ );
+ }
+
+ #[test]
+ fn detect_much_worse_atomic() {
+ assert_suggestion_result("much worst", lint_group(), "much worse");
+ }
+
+ #[test]
+ fn detect_much_worse_real_world() {
+ assert_suggestion_result(
+ "the generated image quality is much worst (actually nearly broken)",
+ lint_group(),
+ "the generated image quality is much worse (actually nearly broken)",
+ );
+ }
+
+ #[test]
+ fn detect_turn_for_the_worse_atomic() {
+ assert_suggestion_result("turn for the worst", lint_group(), "turn for the worse");
+ }
+
+ #[test]
+ fn detect_turn_for_the_worse_real_world() {
+ assert_suggestion_result(
+ "Very surprised to see this repo take such a turn for the worst.",
+ lint_group(),
+ "Very surprised to see this repo take such a turn for the worse.",
+ );
+ }
+
+ #[test]
+ fn detect_worst_and_worst_atomic() {
+ assert_suggestion_result("worst and worst", lint_group(), "worse and worse");
+ }
+
+ #[test]
+ fn detect_worst_and_worst_real_world() {
+ assert_suggestion_result(
+ "This control-L trick does not work for me. The padding is getting worst and worst.",
+ lint_group(),
+ "This control-L trick does not work for me. The padding is getting worse and worse.",
+ );
+ }
+
+ #[test]
+ fn detect_worse_and_worst_real_world() {
+ assert_suggestion_result(
+ "This progressively got worse and worst to the point that the machine (LEAD 1010) stopped moving alltogether.",
+ lint_group(),
+ "This progressively got worse and worse to the point that the machine (LEAD 1010) stopped moving alltogether.",
+ );
+ }
+
+ #[test]
+ fn detect_worse_than_atomic() {
+ assert_suggestion_result("worst than", lint_group(), "worse than");
+ }
+
+ #[test]
+ fn detect_worse_than_real_world() {
+ assert_suggestion_result(
+ "Project real image - inversion quality is worst than in StyleGAN2",
+ lint_group(),
+ "Project real image - inversion quality is worse than in StyleGAN2",
+ );
+ }
+
+ #[test]
+ fn detect_worst_ever_atomic() {
+ assert_suggestion_result("worse ever", lint_group(), "worst ever");
+ }
+
+ #[test]
+ fn detect_worst_ever_real_world() {
+ assert_suggestion_result(
+ "The Bcl package family is one of the worse ever published by Microsoft.",
+ lint_group(),
+ "The Bcl package family is one of the worst ever published by Microsoft.",
+ );
+ }
+
+ #[test]
+ fn detect_monumentous_atomic() {
+ assert_suggestion_result("monumentous", lint_group(), "momentous");
+ }
+
+ #[test]
+ fn detect_monumentous_real_world() {
+ assert_suggestion_result(
+ "I think that would be a monumentous step in the right direction, and would DEFINATLY turn heads in not just the music industry, but every ...",
+ lint_group(),
+ "I think that would be a momentous step in the right direction, and would DEFINATLY turn heads in not just the music industry, but every ...",
+ );
+ }
+
+ #[test]
+ fn detect_in_anyway_atomic() {
+ assert_suggestion_result("in anyway", lint_group(), "in any way");
+ }
+
+ #[test]
+ fn detect_in_anyway_real_world() {
+ assert_suggestion_result(
+ "The names should not affect your application in anyway and you can override extension names.",
+ lint_group(),
+ "The names should not affect your application in any way and you can override extension names.",
+ );
+ }
+
+ #[test]
+ fn detect_explanation_mark_atomic() {
+ assert_suggestion_result("explanation mark", lint_group(), "exclamation mark");
+ }
+
+ #[test]
+ fn detect_explanation_marks_atomic() {
+ assert_suggestion_result("explanation marks", lint_group(), "exclamation marks");
+ }
+
+ #[test]
+ fn detect_explanation_mark_real_world() {
+ assert_suggestion_result(
+ "Note that circled explanation mark, question mark, plus and arrows may be significantly harder to distinguish than their uncircled variants.",
+ lint_group(),
+ "Note that circled exclamation mark, question mark, plus and arrows may be significantly harder to distinguish than their uncircled variants.",
+ );
+ }
+
+ #[test]
+ fn detect_explanation_marks_real_world() {
+ assert_suggestion_result(
+ "this issue: html: properly handle explanation marks in comments",
+ lint_group(),
+ "this issue: html: properly handle exclamation marks in comments",
+ );
+ }
+
+ #[test]
+ fn detect_explanation_point_atomic() {
+ assert_suggestion_result("explanation point", lint_group(), "exclamation point");
+ }
+
+ #[test]
+ fn detect_explanation_point_real_world() {
+ assert_suggestion_result(
+ "js and makes an offhand mention that you can disable inbuilt plugin with an explanation point (e.g. !error ).",
+ lint_group(),
+ "js and makes an offhand mention that you can disable inbuilt plugin with an exclamation point (e.g. !error ).",
+ );
+ }
+
+ #[test]
+ fn detect_as_early_back_as() {
+ assert_suggestion_result("as early back as", lint_group(), "as far back as");
+ }
+
+ #[test]
+ fn detect_as_early_back_as_real_world() {
+ assert_suggestion_result(
+ "skin overrides also supports a wide variety of minecraft versions - as early back as 1.14.4.",
+ lint_group(),
+ "skin overrides also supports a wide variety of minecraft versions - as far back as 1.14.4.",
+ );
+ }
}