Skip to content

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

feat(core): create initial ToTwoToo rule (#1712)

Elijah Potter936073ff3bd0
diff --git a/harper-core/annotations.json b/harper-core/annotations.json
index 95ecbbe50..29c58da8d 100644
--- a/harper-core/annotations.json
+++ b/harper-core/annotations.json
@@ -521,7 +521,13 @@
"condition": "."
}
],
- "target": [],
+ "target": [
+ {
+ "metadata": {
+ "adverb": {}
+ }
+ }
+ ],
"base_metadata": {},
"rename_ok": true
},
diff --git a/harper-core/src/expr/sequence_expr.rs b/harper-core/src/expr/sequence_expr.rs
index 925c577df..ccc17adb6 100644
--- a/harper-core/src/expr/sequence_expr.rs
+++ b/harper-core/src/expr/sequence_expr.rs
@@ -317,6 +317,7 @@ impl SequenceExpr {
})
}
+ gen_then_from_is!(sentence_terminator);
// More than two kinds
/// Match a token where any of the token kind predicates returns true.
diff --git a/harper-core/src/linting/ask_no_preposition.rs b/harper-core/src/linting/ask_no_preposition.rs
index af852336a..11e88be74 100644
--- a/harper-core/src/linting/ask_no_preposition.rs
+++ b/harper-core/src/linting/ask_no_preposition.rs
@@ -49,7 +49,7 @@ impl ExprLinter for AskNoPreposition {
lint_kind: LintKind::WordChoice,
suggestions: vec![Suggestion::ReplaceWith(Vec::new())],
message: format!(
- "The verb `to {verb} someone` should not be preceded by the preposition “to”."
+ "The verb `to {verb} someone` should not be preceded by the preposition `to`."
),
priority: 63,
})
diff --git a/harper-core/src/linting/discourse_markers.rs b/harper-core/src/linting/discourse_markers.rs
index b474eeffb..ff422743b 100644
--- a/harper-core/src/linting/discourse_markers.rs
+++ b/harper-core/src/linting/discourse_markers.rs
@@ -22,6 +22,7 @@ impl DiscourseMarkers {
"thus",
"instead",
"moreover",
+ "honestly",
"alternatively",
"frankly",
"additionally",
diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rs
index 0d0b65f1d..d607115c9 100644
--- a/harper-core/src/linting/lint_group.rs
+++ b/harper-core/src/linting/lint_group.rs
@@ -116,6 +116,7 @@ use super::the_my::TheMy;
use super::then_than::ThenThan;
use super::thing_think::ThingThink;
use super::throw_rubbish::ThrowRubbish;
+use super::to_two_too::ToTwoToo;
use super::touristic::Touristic;
use super::unclosed_quotes::UnclosedQuotes;
use super::update_place_names::UpdatePlaceNames;
@@ -509,6 +510,7 @@ impl LintGroup {
insert_expr_rule!(ThenThan, true);
insert_expr_rule!(ThingThink, true);
insert_struct_rule!(ThrowRubbish, true);
+ insert_struct_rule!(ToTwoToo, true);
insert_expr_rule!(Touristic, true);
insert_struct_rule!(UnclosedQuotes, true);
insert_expr_rule!(UpdatePlaceNames, true);
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index adbbe968c..428624dbc 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -130,6 +130,7 @@ mod the_my;
mod then_than;
mod thing_think;
mod throw_rubbish;
+mod to_two_too;
mod touristic;
mod unclosed_quotes;
mod update_place_names;
@@ -257,6 +258,7 @@ pub use the_my::TheMy;
pub use then_than::ThenThan;
pub use thing_think::ThingThink;
pub use throw_rubbish::ThrowRubbish;
+pub use to_two_too::ToTwoToo;
pub use touristic::Touristic;
pub use unclosed_quotes::UnclosedQuotes;
pub use update_place_names::UpdatePlaceNames;
diff --git a/harper-core/src/linting/to_two_too/mod.rs b/harper-core/src/linting/to_two_too/mod.rs
new file mode 100644
index 000000000..7eadbfbfa
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/mod.rs
@@ -0,0 +1,396 @@
+mod to_too_adjective_end;
+mod to_too_adjective_punct;
+mod to_too_adjverb_ed_punct;
+mod to_too_adverb;
+mod to_too_chunk_start_comma;
+mod to_too_degree_words;
+mod to_too_eos;
+mod to_too_pronoun_end;
+mod too_to;
+
+use super::merge_linters::merge_linters;
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+use to_too_adjective_end::ToTooAdjectiveEnd;
+use to_too_adjective_punct::ToTooAdjectivePunct;
+use to_too_adjverb_ed_punct::ToTooAdjVerbEdPunct;
+use to_too_adverb::ToTooAdverb;
+use to_too_chunk_start_comma::ToTooChunkStartComma;
+use to_too_degree_words::ToTooDegreeWords;
+use to_too_eos::ToTooEos;
+use to_too_pronoun_end::ToTooPronounEnd;
+use too_to::TooTo;
+
+merge_linters!(
+ ToTwoToo =>
+ ToTooAdjectiveEnd,
+ ToTooAdjectivePunct,
+ ToTooAdverb,
+ ToTooAdjVerbEdPunct,
+ ToTooChunkStartComma,
+ ToTooDegreeWords,
+ ToTooPronounEnd,
+ ToTooEos,
+ TooTo
+ => "Corrects homophone confusion between `to` and `too`."
+);
+
+#[cfg(test)]
+mod tests {
+ use crate::linting::tests::{assert_lint_count, assert_no_lints, assert_suggestion_result};
+
+ use super::ToTwoToo;
+
+ #[test]
+ fn fixes_to_ambitious() {
+ assert_suggestion_result(
+ "The project scope is to ambitious",
+ ToTwoToo::default(),
+ "The project scope is too ambitious",
+ );
+ }
+
+ #[test]
+ fn fixes_end_of_sent() {
+ assert_suggestion_result(
+ "She wants ice cream, to.",
+ ToTwoToo::default(),
+ "She wants ice cream, too.",
+ );
+ }
+
+ #[test]
+ fn flags_to_hungry() {
+ assert_lint_count("I am to hungry.", ToTwoToo::default(), 1);
+ }
+
+ #[test]
+ fn no_lint_on_proper_too() {
+ assert_no_lints("I am too hungry.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn flags_to_with_irregular_whitespace() {
+ assert_lint_count("She was to\t tired.", ToTwoToo::default(), 1);
+ assert_lint_count("He felt it was\nto cold.", ToTwoToo::default(), 1);
+ }
+
+ #[test]
+ fn flags_to_with_trailing_punct() {
+ assert_lint_count("He spoke to loud!", ToTwoToo::default(), 1);
+ assert_lint_count("He spoke to loud?", ToTwoToo::default(), 1);
+ assert_lint_count("He spoke to loud.", ToTwoToo::default(), 1);
+ }
+
+ #[test]
+ fn no_lint_to_eat() {
+ assert_no_lints(
+ "Please remember to eat your vegetables.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_to_nashville_or_you() {
+ assert_no_lints("I’m going to Nashville next week.", ToTwoToo::default());
+ assert_no_lints("Talk to you later.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn fixes_too_go() {
+ assert_suggestion_result(
+ "I want too go abroad.",
+ ToTwoToo::default(),
+ "I want to go abroad.",
+ );
+ }
+
+ #[test]
+ fn fixes_too_him() {
+ assert_suggestion_result(
+ "Give it too him as a gift",
+ ToTwoToo::default(),
+ "Give it to him as a gift",
+ );
+ }
+
+ #[test]
+ fn fixes_too_the() {
+ assert_suggestion_result(
+ "We're going too the conference.",
+ ToTwoToo::default(),
+ "We're going to the conference.",
+ );
+ }
+
+ #[test]
+ fn fixes_too_a() {
+ assert_suggestion_result(
+ "We're going too a concert.",
+ ToTwoToo::default(),
+ "We're going to a concert.",
+ );
+ }
+
+ #[test]
+ fn fixes_to_hard() {
+ assert_suggestion_result(
+ "It's not to hard, is it?",
+ ToTwoToo::default(),
+ "It's not too hard, is it?",
+ );
+ }
+
+ #[test]
+ fn no_lint_too_hot() {
+ assert_no_lints("The coffee is too hot to drink.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn no_lint_too_loud() {
+ assert_no_lints(
+ "The music was too loud, making it hard to hear.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_shy() {
+ assert_no_lints("He's too shy to speak in public.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn no_lint_too_sweet() {
+ assert_no_lints("The cake is too sweet for my taste.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn no_lint_too_expensive() {
+ assert_no_lints(
+ "It's too expensive for me to buy right now.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_hard() {
+ assert_no_lints(
+ "She worked too hard and ended up getting sick.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_complicated() {
+ assert_no_lints(
+ "The instructions were too complicated to understand.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_too() {
+ assert_no_lints(
+ "I like apples, and my brother does too.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_too_2() {
+ assert_no_lints(
+ "She's coming to the party, and he is too.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_too_3() {
+ assert_no_lints(
+ "I want to go to the beach, and you do too?",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_too_4() {
+ assert_no_lints(
+ "He's a talented musician, and a great friend too.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_too_5() {
+ assert_no_lints(
+ "The movie was good, and the popcorn was delicious too.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_difficult_too_close() {
+ assert_no_lints(
+ "The problem is too difficult, and the deadline is too close.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_too_good_too_nice() {
+ assert_no_lints(
+ "He's too good at the game, and he's too nice to win.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn allow_young_musicians() {
+ assert_no_lints(
+ "Bringing Hope and Opportunity to Young Musicians",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn allow_semicolon() {
+ assert_no_lints("Attendees can look forward to:", ToTwoToo::default());
+ }
+
+ #[test]
+ fn allow_build_brighter() {
+ assert_no_lints(
+ "We're empowering them to build brighter futures.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn allow_delegate() {
+ assert_no_lints(
+ "I’d like you to consciously delegate one task",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_soundscapes() {
+ assert_no_lints(
+ "Soundscapes are not merely environmental features; they are integral to human identity and cultural expression.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_speed_flexibility() {
+ assert_no_lints(
+ "Its speed, flexibility, and seamless integration with FZF make it a compelling alternative to traditional fuzzy finding solutions.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_explicitly_cast() {
+ assert_no_lints(
+ "Attempted to explicitly cast the result back to a string",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_buried_under_data() {
+ assert_no_lints(
+ "They felt buried under the data, unable to proactively address emerging threats.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_familiarize() {
+ assert_no_lints(
+ "Familiarize yourself with these resources to learn how to effectively utilize the plugin’s features.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_great_deal_of_energy() {
+ assert_no_lints(
+ "It takes a great deal of energy to consistently operate under that kind of pressure.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_occasionally_troubleshoot() {
+ assert_no_lints(
+ "Just be prepared to occasionally troubleshoot the debugger itself.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn ccoveille_suggestion() {
+ assert_no_lints("He goes too far with bets.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn no_lint_auto_detect_debuggers() {
+ assert_no_lints(
+ "Daprio attempts to auto-detect debugger servers and configurations, which can save significant time, especially for common languages.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_commitment_open_source() {
+ assert_no_lints(
+ "I believe a commitment to open-source solutions and internal skill development would ultimately yield a more sustainable and ethical approach.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_feeling_confident_dominate() {
+ assert_no_lints(
+ "I'm feeling confident, and I suspect you all should be too – because I’m about to dominate.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_egyptian_smiling_faces_commentary() {
+ assert_no_lints(
+ "Today I learned that the ubiquitous, seemingly cheerful faces carved into ancient Egyptian relief sculptures – often referred to as “smiling faces” – weren’t simply a stylistic choice reflecting happiness. Recent scholarship suggests they functioned as a subtle, often satirical, form of social commentary, particularly targeting individuals who were arrogant, boastful, or otherwise deserving of ridicule.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_intended_to_leave_it_to() {
+ assert_no_lints(
+ "Beatrice never explicitly said who she intended to leave it to.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_time_for_good_girl_to_bed() {
+ assert_no_lints("Time for this good girl to go to bed.", ToTwoToo::default());
+ }
+
+ #[test]
+ fn no_lint_connected_to_many_other_fields() {
+ assert_no_lints(
+ "The study is connected to many other fields.",
+ ToTwoToo::default(),
+ );
+ }
+
+ #[test]
+ fn no_lint_till_she_too_began_dreaming() {
+ assert_no_lints(
+ "till she too began dreaming after a fashion",
+ ToTwoToo::default(),
+ );
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too.rs b/harper-core/src/linting/to_two_too/to_too.rs
new file mode 100644
index 000000000..7a2e80a04
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too.rs
@@ -0,0 +1,267 @@
+use crate::char_string::CharStringExt;
+use crate::patterns::WhitespacePattern;
+use crate::{
+ Token, TokenKind,
+ expr::{AnchorEnd, AnchorStart, Expr, FirstMatchOf, SequenceExpr},
+};
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct ToToo {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for ToToo {
+ fn default() -> Self {
+ // to + adjective (but not also a verb), allowing optional following word/punct.
+ // Decision about linting is refined in `match_to_lint` to avoid false positives.
+ let to_before_adjective_loose = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_adjective,
+ TokenKind::is_verb,
+ &["standard"],
+ )
+ .then_optional(WhitespacePattern)
+ .then_optional(SequenceExpr::default().then_any_word())
+ .then_optional(WhitespacePattern)
+ .then_optional(SequenceExpr::default().then_punctuation());
+
+ // to + adverb + (punct | end)
+ // to + adverb + (punct | end)
+ let to_before_adverb = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_adverb,
+ |_| false,
+ &["as"],
+ )
+ .then_optional(WhitespacePattern)
+ .then_any_of(vec![
+ Box::new(SequenceExpr::default().then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’"],
+ )),
+ Box::new(SequenceExpr::default().then_unless(SequenceExpr::default().t_any())),
+ ]);
+
+ // to + adjective-verb (past participle like "tired") + punctuation (non-quote, non-dash)
+ // Helps catch cases like "to tired." while avoiding base verbs like "to dominate."
+ let to_before_adj_verb_ed_punct = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then(|tok: &Token, src: &[char]| {
+ tok.kind.is_adjective()
+ && tok.kind.is_verb()
+ && !tok.kind.is_noun()
+ && tok
+ .span
+ .get_content(src)
+ .iter()
+ .collect::<String>()
+ .to_lowercase()
+ .ends_with("ed")
+ })
+ .then_optional(WhitespacePattern)
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’", "-", "–", "—"],
+ );
+
+ // to + adjective (any, including words that can also be verbs) + punctuation (non-quote, non-dash)
+ let to_before_adjective_strict_punct = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_adjective,
+ TokenKind::is_verb,
+ &["standard"],
+ )
+ .then_optional(WhitespacePattern)
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’", "-", "–", "—"],
+ );
+
+ // to + (many|much|few) + (punct|end) to avoid "connected to many ..."
+ let to_before_degree_words = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then_word_set(&["many", "much", "few"])
+ .t_ws_opt()
+ .then_any_of(vec![
+ Box::new(SequenceExpr::default().then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’", "-", "–", "—"],
+ )),
+ Box::new(AnchorEnd),
+ ]);
+
+ let chunk_start_to_pause = SequenceExpr::default()
+ .then(AnchorStart)
+ .t_aco("to")
+ .then_optional(WhitespacePattern)
+ .then_comma();
+
+ // (start|punct) + pronoun + to + (punct_without_quotes | end)
+ let pronoun_to_end = SequenceExpr::default()
+ .then_any_of(vec![
+ Box::new(SequenceExpr::default().then_anchor_start()),
+ Box::new(
+ SequenceExpr::default()
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’"],
+ )
+ .t_ws_opt(),
+ ),
+ ])
+ .then_pronoun()
+ .t_ws()
+ .t_aco("to")
+ .then_any_of(vec![
+ Box::new(SequenceExpr::default().then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’"],
+ )),
+ Box::new(AnchorEnd),
+ ]);
+
+ let expr = FirstMatchOf::new(vec![
+ Box::new(to_before_adj_verb_ed_punct),
+ Box::new(to_before_adjective_strict_punct),
+ Box::new(to_before_adverb),
+ Box::new(to_before_degree_words),
+ Box::new(pronoun_to_end),
+ Box::new(chunk_start_to_pause),
+ Box::new(to_before_adjective_loose),
+ ]);
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for ToToo {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, tokens: &[Token], source: &[char]) -> Option<Lint> {
+ // The expression ensures only valid contexts reach here.
+ let to_tok = tokens.iter().find(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })?;
+
+ // Decide if this match should lint based on the token following `to`.
+ // Find the next non-whitespace token after `to` (if any)
+ let to_index = tokens
+ .iter()
+ .position(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })
+ .unwrap_or(0);
+
+ // Find index of the first non-whitespace token after `to`
+ let mut idx = to_index + 1;
+ while idx < tokens.len() && tokens[idx].kind.is_whitespace() {
+ idx += 1;
+ }
+
+ let should_lint = if idx < tokens.len() {
+ let next = &tokens[idx];
+ let next_text: String = next.span.get_content(source).iter().collect();
+ let next_lower = next_text.to_lowercase();
+ // Find token after `next` ignoring whitespace, if any
+ let mut j = idx + 1;
+ while j < tokens.len() && tokens[j].kind.is_whitespace() {
+ j += 1;
+ }
+ let after_next_non_ws = if j < tokens.len() {
+ Some(&tokens[j])
+ } else {
+ None
+ };
+
+ // Branch: degree words
+ if matches!(next_lower.as_str(), "many" | "much" | "few") {
+ true
+ // Branch: punctuation or end after pronoun (", to.", "Me to!")
+ } else if next.kind.is_punctuation() {
+ true
+ // Branch: adverb
+ } else if next.kind.is_adverb() {
+ // Only when followed by non-quote, non-dash punctuation or end-of-slice
+ match after_next_non_ws {
+ None => true,
+ Some(t) => {
+ if t.kind.is_punctuation() {
+ let punct: String = t.span.get_content(source).iter().collect();
+ !matches!(
+ punct.as_str(),
+ "`" | "\"" | "'" | "“" | "”" | "‘" | "’" | "-" | "–" | "—"
+ )
+ } else {
+ false
+ }
+ }
+ }
+ // Branch: adjective
+ } else if next.kind.is_adjective() {
+ // Avoid specific exception (commonly prepositional phrase)
+ if next_lower == "standard" {
+ return None;
+ }
+ match after_next_non_ws {
+ None => true, // end-of-slice (no following token captured)
+ Some(t) if t.kind.is_punctuation() => {
+ let punct: String = t.span.get_content(source).iter().collect();
+ !matches!(
+ punct.as_str(),
+ "`" | "\"" | "'" | "“" | "”" | "‘" | "’" | "-" | "–" | "—"
+ )
+ }
+ // If a word follows, do not lint (likely "to ADJ NOUN" prepositional phrase)
+ _ => false,
+ }
+ } else {
+ false
+ }
+ } else {
+ // No token after `to` (end of chunk) — don't lint.
+ false
+ };
+
+ if !should_lint {
+ return None;
+ }
+
+ Some(Lint {
+ span: to_tok.span,
+ lint_kind: LintKind::WordChoice,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ to_tok.span.get_content(source),
+ )],
+ message: "Use `too` here to mean ‘also’ or an excessive degree.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &str {
+ "Corrects mistaken `to` to `too` when it means ‘also’ or an excessive degree."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too_adjective_end.rs b/harper-core/src/linting/to_two_too/to_too_adjective_end.rs
new file mode 100644
index 000000000..327f78135
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too_adjective_end.rs
@@ -0,0 +1,96 @@
+use crate::{
+ Token, TokenKind,
+ char_string::CharStringExt,
+ expr::{Expr, SequenceExpr},
+ patterns::WhitespacePattern,
+};
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct ToTooAdjectiveEnd {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for ToTooAdjectiveEnd {
+ fn default() -> Self {
+ let expr = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_adjective,
+ TokenKind::is_verb,
+ &["standard"],
+ )
+ .then_optional(WhitespacePattern)
+ .then_optional(SequenceExpr::default().then_any_word())
+ .then_optional(WhitespacePattern)
+ .then_optional(SequenceExpr::default().then_punctuation());
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for ToTooAdjectiveEnd {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, tokens: &[Token], source: &[char]) -> Option<Lint> {
+ // Find the `to` token
+ let to_index = tokens.iter().position(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })?;
+
+ // First non-whitespace after `to` should be the adjective
+ let mut idx = to_index + 1;
+ while idx < tokens.len() && tokens[idx].kind.is_whitespace() {
+ idx += 1;
+ }
+ if idx >= tokens.len() || !tokens[idx].kind.is_adjective() {
+ return None;
+ }
+
+ // Find the next non-whitespace after the adjective
+ let mut j = idx + 1;
+ while j < tokens.len() && tokens[j].kind.is_whitespace() {
+ j += 1;
+ }
+
+ let should_lint = if j >= tokens.len() {
+ true
+ } else if tokens[j].kind.is_punctuation() {
+ let punct: String = tokens[j].span.get_content(source).iter().collect();
+ !matches!(
+ punct.as_str(),
+ "`" | "\"" | "'" | "“" | "”" | "‘" | "’" | "-" | "–" | "—"
+ )
+ } else {
+ false
+ };
+
+ if !should_lint {
+ return None;
+ }
+
+ let to_tok = &tokens[to_index];
+
+ Some(Lint {
+ span: to_tok.span,
+ lint_kind: LintKind::WordChoice,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ to_tok.span.get_content(source),
+ )],
+ message: "Use `too` here to mean ‘also’ or an excessive degree.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &str {
+ "Detects `to` before an adjective when no word follows (end or punct)."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too_adjective_punct.rs b/harper-core/src/linting/to_two_too/to_too_adjective_punct.rs
new file mode 100644
index 000000000..5f81806de
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too_adjective_punct.rs
@@ -0,0 +1,60 @@
+use crate::patterns::WhitespacePattern;
+use crate::{
+ Token, TokenKind,
+ char_string::CharStringExt,
+ expr::{Expr, SequenceExpr},
+};
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct ToTooAdjectivePunct {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for ToTooAdjectivePunct {
+ fn default() -> Self {
+ let expr = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_adjective,
+ TokenKind::is_verb,
+ &["standard"],
+ )
+ .then_optional(WhitespacePattern)
+ .then_sentence_terminator();
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for ToTooAdjectivePunct {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let to_tok = tokens.iter().find(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })?;
+
+ Some(Lint {
+ span: to_tok.span,
+ lint_kind: LintKind::WordChoice,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ to_tok.span.get_content(source),
+ )],
+ message: "Use `too` here to mean ‘also’ or an excessive degree.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &str {
+ "Detects `to` before an adjective when followed by punctuation."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too_adjverb_ed_punct.rs b/harper-core/src/linting/to_two_too/to_too_adjverb_ed_punct.rs
new file mode 100644
index 000000000..77c3b8b33
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too_adjverb_ed_punct.rs
@@ -0,0 +1,65 @@
+use crate::char_string::CharStringExt;
+use crate::{
+ Token,
+ expr::{Expr, SequenceExpr},
+};
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct ToTooAdjVerbEdPunct {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for ToTooAdjVerbEdPunct {
+ fn default() -> Self {
+ let expr = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then(|tok: &crate::Token, src: &[char]| {
+ tok.kind.is_adjective()
+ && tok.kind.is_verb()
+ && !tok.kind.is_noun()
+ && tok
+ .span
+ .get_content(src)
+ .iter()
+ .collect::<String>()
+ .to_lowercase()
+ .ends_with("ed")
+ })
+ .then_sentence_terminator();
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for ToTooAdjVerbEdPunct {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let to_tok = tokens.iter().find(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })?;
+
+ Some(Lint {
+ span: to_tok.span,
+ lint_kind: LintKind::WordChoice,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ to_tok.span.get_content(source),
+ )],
+ message: "Use `too` here to mean ‘also’ or an excessive degree.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &str {
+ "Detects `to` before words that are adj/verb ending with `ed`, followed by punctuation."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too_adverb.rs b/harper-core/src/linting/to_two_too/to_too_adverb.rs
new file mode 100644
index 000000000..124e7d25e
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too_adverb.rs
@@ -0,0 +1,63 @@
+use crate::patterns::WhitespacePattern;
+use crate::{
+ Token, TokenKind,
+ char_string::CharStringExt,
+ expr::{AnchorEnd, Expr, SequenceExpr},
+};
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct ToTooAdverb {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for ToTooAdverb {
+ fn default() -> Self {
+ let expr = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then_kind_is_but_is_not_except(TokenKind::is_adverb, |_| false, &["as"])
+ .then_optional(WhitespacePattern)
+ .then_any_of(vec![
+ Box::new(SequenceExpr::default().then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’", "-", "–", "—"],
+ )),
+ Box::new(AnchorEnd),
+ ]);
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for ToTooAdverb {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let to_tok = tokens.iter().find(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })?;
+
+ Some(Lint {
+ span: to_tok.span,
+ lint_kind: LintKind::WordChoice,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ to_tok.span.get_content(source),
+ )],
+ message: "Use `too` here to mean ‘also’ or an excessive degree.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &str {
+ "Detects `to` before an adverb when it should be `too`."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too_chunk_start_comma.rs b/harper-core/src/linting/to_two_too/to_too_chunk_start_comma.rs
new file mode 100644
index 000000000..f9ae055a7
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too_chunk_start_comma.rs
@@ -0,0 +1,55 @@
+use crate::{
+ Token,
+ char_string::CharStringExt,
+ expr::{AnchorStart, Expr, SequenceExpr},
+ patterns::WhitespacePattern,
+};
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct ToTooChunkStartComma {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for ToTooChunkStartComma {
+ fn default() -> Self {
+ let expr = SequenceExpr::default()
+ .then(AnchorStart)
+ .t_aco("to")
+ .then_optional(WhitespacePattern)
+ .then_comma();
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for ToTooChunkStartComma {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let to_tok = tokens.iter().find(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })?;
+
+ Some(Lint {
+ span: to_tok.span,
+ lint_kind: LintKind::WordChoice,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ to_tok.span.get_content(source),
+ )],
+ message: "Use `too` here to mean ‘also’ or an excessive degree.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &str {
+ "Detects `to` at the start of a clause before a comma."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too_degree_words.rs b/harper-core/src/linting/to_two_too/to_too_degree_words.rs
new file mode 100644
index 000000000..32eea34da
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too_degree_words.rs
@@ -0,0 +1,63 @@
+use crate::{
+ Token, TokenKind,
+ char_string::CharStringExt,
+ expr::{AnchorEnd, Expr, SequenceExpr},
+};
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct ToTooDegreeWords {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for ToTooDegreeWords {
+ fn default() -> Self {
+ // Only flag `to` before degree words when the phrase ends the clause
+ // (punctuation or end). Avoids false positives like "connected to many X".
+ let expr = SequenceExpr::default()
+ .t_aco("to")
+ .t_ws()
+ .then_word_set(&["many", "much", "few"])
+ .then_any_of(vec![
+ Box::new(SequenceExpr::default().then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’", "-", "–", "—"],
+ )),
+ Box::new(AnchorEnd),
+ ]);
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for ToTooDegreeWords {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let to_tok = tokens.iter().find(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })?;
+
+ Some(Lint {
+ span: to_tok.span,
+ lint_kind: LintKind::WordChoice,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ to_tok.span.get_content(source),
+ )],
+ message: "Use `too` here to mean ‘also’ or an excessive degree.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &str {
+ "Detects `to` used before degree words like `many`, `much`, or `few`."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too_eos.rs b/harper-core/src/linting/to_two_too/to_too_eos.rs
new file mode 100644
index 000000000..f26e61dcd
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too_eos.rs
@@ -0,0 +1,56 @@
+use crate::{
+ Document,
+ expr::{ExprExt, SequenceExpr},
+ linting::Linter,
+};
+
+use super::{Lint, LintKind, Suggestion};
+
+pub struct ToTooEos {
+ expr: SequenceExpr,
+}
+
+impl ToTooEos {
+ pub fn new() -> Self {
+ Self {
+ expr: SequenceExpr::default()
+ .then_comma()
+ .t_ws()
+ .t_aco("to")
+ .then_sentence_terminator(),
+ }
+ }
+}
+
+impl Default for ToTooEos {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl Linter for ToTooEos {
+ fn lint(&mut self, document: &Document) -> Vec<Lint> {
+ let matches = self.expr.iter_matches_in_doc(document);
+
+ matches
+ .map(|m| {
+ let tok = &m.get_content(document.get_tokens())[2];
+
+ Lint {
+ span: tok.span,
+ lint_kind: LintKind::Typo,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ tok.span.get_content(document.get_source()),
+ )],
+ message: "Use `too` when expressing similarity.".to_owned(),
+ priority: 63,
+ }
+ })
+ .collect()
+ }
+
+ fn description(&self) -> &str {
+ "Identifies incorrect usage of the term `to` at the end of a sentence."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/to_too_pronoun_end.rs b/harper-core/src/linting/to_two_too/to_too_pronoun_end.rs
new file mode 100644
index 000000000..2263e3aa8
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/to_too_pronoun_end.rs
@@ -0,0 +1,76 @@
+use crate::{
+ Token, TokenKind,
+ char_string::CharStringExt,
+ expr::{AnchorEnd, AnchorStart, Expr, SequenceExpr},
+ patterns::WhitespacePattern,
+};
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct ToTooPronounEnd {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for ToTooPronounEnd {
+ fn default() -> Self {
+ // Match at clause start or after punctuation to avoid cases like
+ // "leave it to." where `it` is an object pronoun.
+ let expr = SequenceExpr::default()
+ .then_any_of(vec![
+ Box::new(SequenceExpr::default().then(AnchorStart)),
+ Box::new(
+ SequenceExpr::default()
+ .then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’"],
+ )
+ .then_optional(WhitespacePattern),
+ ),
+ ])
+ .then_pronoun()
+ .t_ws()
+ .t_aco("to")
+ .then_any_of(vec![
+ Box::new(SequenceExpr::default().then_kind_is_but_is_not_except(
+ TokenKind::is_punctuation,
+ |_| false,
+ &["`", "\"", "'", "“", "”", "‘", "’"],
+ )),
+ Box::new(AnchorEnd),
+ ]);
+
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for ToTooPronounEnd {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let to_tok = tokens.iter().find(|t| {
+ t.span
+ .get_content(source)
+ .eq_ignore_ascii_case_chars(&['t', 'o'])
+ })?;
+
+ Some(Lint {
+ span: to_tok.span,
+ lint_kind: LintKind::WordChoice,
+ suggestions: vec![Suggestion::replace_with_match_case_str(
+ "too",
+ to_tok.span.get_content(source),
+ )],
+ message: "Use `too` here to mean ‘also’ or an excessive degree.".to_string(),
+ ..Default::default()
+ })
+ }
+
+ fn description(&self) -> &str {
+ "Detects `to` after a pronoun at clause end (e.g., `Me to!`)."
+ }
+}
diff --git a/harper-core/src/linting/to_two_too/too_to.rs b/harper-core/src/linting/to_two_too/too_to.rs
new file mode 100644
index 000000000..d67bc11b8
--- /dev/null
+++ b/harper-core/src/linting/to_two_too/too_to.rs
@@ -0,0 +1,60 @@
+use harper_brill::UPOS;
+
+use crate::Token;
+use crate::expr::Expr;
+use crate::expr::SequenceExpr;
+use crate::patterns::UPOSSet;
+
+use super::{ExprLinter, Lint, LintKind, Suggestion};
+
+pub struct TooTo {
+ expr: Box<dyn Expr>,
+}
+
+impl Default for TooTo {
+ fn default() -> Self {
+ let expr = SequenceExpr::aco("too").t_ws().then(UPOSSet::new(&[
+ UPOS::NOUN,
+ UPOS::PRON,
+ UPOS::PROPN,
+ UPOS::VERB,
+ UPOS::DET,
+ ]));
+ Self {
+ expr: Box::new(expr),
+ }
+ }
+}
+
+impl ExprLinter for TooTo {
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let too_token = &matched_tokens[0];
+ let span = too_token.span;
+ let text = span.get_content(source);
+
+ if let Some(next_tok) = matched_tokens.get(2)
+ && next_tok.kind.is_upos(UPOS::VERB)
+ && !next_tok.kind.is_verb_lemma()
+ {
+ return None;
+ }
+
+ Some(Lint {
+ span,
+ lint_kind: LintKind::Typo,
+ suggestions: vec![
+ Suggestion::replace_with_match_case("to".chars().collect(), text)
+ ],
+ message: "Use the infinitive marker `to` here instead of the adverb `too`, which indicates excess degree.".to_string(),
+ priority: 31,
+ })
+ }
+
+ fn description(&self) -> &'static str {
+ "Handles the transition from `too` -> `to`."
+ }
+}
diff --git a/harper-core/src/token_kind.rs b/harper-core/src/token_kind.rs
index 5cfc1bcf9..76615bbf3 100644
--- a/harper-core/src/token_kind.rs
+++ b/harper-core/src/token_kind.rs
@@ -145,6 +145,14 @@ impl TokenKind {
metadata.common
}
+ /// Checks whether the token is a member of a nominal phrase.
+ pub fn is_np_member(&self) -> bool {
+ let Word(Some(metadata)) = self else {
+ return false;
+ };
+ metadata.np_member.unwrap_or(false)
+ }
+
/// Checks whether a word token is out-of-vocabulary (not found in the dictionary).
///
/// Returns `true` if the token is a word that was not found in the dictionary,
diff --git a/harper-core/tests/text/linters/The Great Gatsby.snap.yml b/harper-core/tests/text/linters/The Great Gatsby.snap.yml
index 32a3899f7..d5707b265 100644
--- a/harper-core/tests/text/linters/The Great Gatsby.snap.yml
+++ b/harper-core/tests/text/linters/The Great Gatsby.snap.yml
@@ -2066,6 +2066,16 @@ Suggest:
+Lint: WordChoice (127 priority)
+Message: |
+ 1667 | “Don’t ask me,” said Owl Eyes, washing his hands of the whole matter. “I know
+ 1668 | very little about driving—next to nothing. It happened, and that’s all I know.”
+ | ^~ Use `too` here to mean ‘also’ or an excessive degree.
+Suggest:
+ - Replace with: “too”
+
+
+
Lint: Spelling (63 priority)
Message: |
1683 | The shock that followed this declaration found voice in a sustained “Ah-h-h!” as
@@ -4670,6 +4680,15 @@ Message: |
+Lint: WordChoice (127 priority)
+Message: |
+ 3353 | inhabitants along a short-cut from nothing to nothing. She saw something awful
+ | ^~ Use `too` here to mean ‘also’ or an excessive degree.
+Suggest:
+ - Replace with: “too”
+
+
+
Lint: Spelling (63 priority)
Message: |
3389 | Daisy began to sing with the music in a husky, rythmic whisper, bringing out a
@@ -6606,6 +6625,24 @@ Suggest:
+Lint: WordChoice (127 priority)
+Message: |
+ 5065 | “Have you got a church you go to sometimes, George? Maybe even if you haven’t
+ | ^~ Use `too` here to mean ‘also’ or an excessive degree.
+Suggest:
+ - Replace with: “too”
+
+
+
+Lint: WordChoice (127 priority)
+Message: |
+ 5069 | “Don’t belong to any.”
+ | ^~ Use `too` here to mean ‘also’ or an excessive degree.
+Suggest:
+ - Replace with: “too”
+
+
+
Lint: Spelling (63 priority)
Message: |
5087 | Michaelis opened the drawer nearest his hand. There was nothing in it but a
diff --git a/harper-core/tests/text/tagged/Computer science.md b/harper-core/tests/text/tagged/Computer science.md
index 3db72b220..77dd691e3 100644
--- a/harper-core/tests/text/tagged/Computer science.md
+++ b/harper-core/tests/text/tagged/Computer science.md
@@ -119,7 +119,7 @@
> algorithm to compute the Bernoulli numbers , which is considered to be the first
# NSg P NSg/VB D NPr+ NPrPl/V3+ . I/C+ VL3 VP/J P NSg/VXB D NSg/VB/J
> published algorithm ever specifically tailored for implementation on a computer .
-# VP/J NSg J W? VP/J C/P NSg+ J/P D/P NSg/VB+ .
+# VP/J NSg J R VP/J C/P NSg+ J/P D/P NSg/VB+ .
> Around 1885 , Herman Hollerith invented the tabulator , which used punched cards
# J/P # . NPr+ NPr VP/J D NSg . I/C+ VP/J VP/J NPl/V3+
> to process statistical information ; eventually his company became part of IBM .
@@ -143,7 +143,7 @@
> demonstrated the feasibility of an electromechanical analytical engine , on which
# VP/J D Nᴹ P D/P ? J NSg/VB+ . J/P I/C+
> commands could be typed and the results printed automatically . In 1937 , one
-# NPl/V3+ NSg/VXB NSg/VXB VP/J VB/C D NPl/V3+ VP/J W? . NPr/J/P # . NSg/I/VB/J
+# NPl/V3+ NSg/VXB NSg/VXB VP/J VB/C D NPl/V3+ VP/J R . NPr/J/P # . NSg/I/VB/J
> hundred years after Babbage's impossible dream , Howard Aiken convinced IBM ,
# NSg NPl+ P NSg$ NSg/J NSg/VB/J+ . NPr+ NPr VP/J NPr+ .
> which was making all kinds of punched card equipment and was also in the
diff --git a/harper-core/tests/text/tagged/Spell.US.md b/harper-core/tests/text/tagged/Spell.US.md
index 63820ec9e..25d42a5d7 100644
--- a/harper-core/tests/text/tagged/Spell.US.md
+++ b/harper-core/tests/text/tagged/Spell.US.md
@@ -7,7 +7,7 @@
>
#
> To achieve this , the filename of this file contains `.US , which will tell the snapshot generator to use the American dialect , rather than trying to use an automatically detected dialect .
-# P VB I/Ddem+ . D NSg P I/Ddem NSg/VB+ V3 Unlintable . I/C+ NPr/VXB NPr/VB D NSg/VB+ NSg P N🅪Sg/VB D NPr/J NSg+ . NPr/VB/J/R C/P Nᴹ/Vg/J P N🅪Sg/VB D/P W? VP/J NSg+ .
+# P VB I/Ddem+ . D NSg P I/Ddem NSg/VB+ V3 Unlintable . I/C+ NPr/VXB NPr/VB D NSg/VB+ NSg P N🅪Sg/VB D NPr/J NSg+ . NPr/VB/J/R C/P Nᴹ/Vg/J P N🅪Sg/VB D/P R VP/J NSg+ .
>
#
> Words
diff --git a/harper-core/tests/text/tagged/The Great Gatsby.md b/harper-core/tests/text/tagged/The Great Gatsby.md
index 9783ef58a..0a0fe7197 100644
--- a/harper-core/tests/text/tagged/The Great Gatsby.md
+++ b/harper-core/tests/text/tagged/The Great Gatsby.md
@@ -489,7 +489,7 @@
>
#
> “ Do they miss me ? ” she cried ecstatically .
-# . NSg/VXB IPl+ NSg/VB NPr/ISg+ . . ISg+ VP/J W? .
+# . NSg/VXB IPl+ NSg/VB NPr/ISg+ . . ISg+ VP/J R .
>
#
> “ The whole town is desolate . All the cars have the left rear wheel painted black
@@ -801,7 +801,7 @@
>
#
> “ I’ll tell you a family secret , ” she whispered enthusiastically . “ It’s about the
-# . W? NPr/VB ISgPl+ D/P N🅪Sg/J+ NSg/VB/J . . ISg+ VP/J W? . . W? J/P D
+# . W? NPr/VB ISgPl+ D/P N🅪Sg/J+ NSg/VB/J . . ISg+ VP/J R . . W? J/P D
> butler’s nose . Do you want to hear about the butler’s nose ? ”
# NSg$ NSg/VB+ . NSg/VXB ISgPl+ NSg/VB P VB J/P D NSg$ NSg/VB+ . .
>
@@ -1605,7 +1605,7 @@
>
#
> “ I think it’s cute , ” said Mrs . Wilson enthusiastically . “ How much is it ? ”
-# . ISg/#r+ NSg/VB W? J . . VP/J NPl+ . NPr+ W? . . NSg/C NSg/I/J/R/Dq VL3 NPr/ISg+ . .
+# . ISg/#r+ NSg/VB W? J . . VP/J NPl+ . NPr+ R . . NSg/C NSg/I/J/R/Dq VL3 NPr/ISg+ . .
>
#
> “ That dog ? ” He looked at it admiringly . “ That dog will cost you ten dollars . ”
@@ -1701,7 +1701,7 @@
> full of straw and some milk , to which he added on his own initiative a tin of
# NSg/VB/J P N🅪Sg/VB/J VB/C I/J/R/Dq+ N🅪Sg/VB+ . P I/C+ NPr/ISg+ VP/J J/P ISg/D$+ NSg/VB/J NSg/J+ D/P N🅪Sg/VB/J P
> large , hard dog - biscuits — one of which decomposed apathetically in the saucer of
-# NSg/J . N🅪Sg/J+ NSg/VB/J+ . NPl . NSg/I/VB/J P I/C+ VP/J W? NPr/J/P D NSg/VB P
+# NSg/J . N🅪Sg/J+ NSg/VB/J+ . NPl . NSg/I/VB/J P I/C+ VP/J R NPr/J/P D NSg/VB P
> milk all afternoon . Meanwhile Tom brought out a bottle of whiskey from a locked
# N🅪Sg/VB+ NSg/I/J/C/Dq N🅪Sg+ . NSg NPr/VB+ VP NSg/VB/J/R/P D/P NSg/VB P NSg P D/P VP/J
> bureau door .
@@ -2807,7 +2807,7 @@
> tortuously , fashionably , and keeping in the corners — and a great number of single
# R . R . VB/C Nᴹ/Vg/J NPr/J/P D + . VB/C D/P NSg/J N🅪Sg/VB/JC P NSg/VB/J
> girls dancing individualistically or relieving the orchestra for a moment of the
-# NPl/V3+ Nᴹ/Vg/J W? NPr/C Nᴹ/Vg/J D NSg+ C/P D/P NSg P D
+# NPl/V3+ Nᴹ/Vg/J R NPr/C Nᴹ/Vg/J D NSg+ C/P D/P NSg P D
> burden of the banjo or the traps . By midnight the hilarity had increased . A
# NSg/VB P D NSg/VB NPr/C D NPl/V3 . NSg/J/P NSg/J+ D NSg VB VP/J . D/P
> celebrated tenor had sung in Italian , and a notorious contralto had sung in
@@ -5375,7 +5375,7 @@
>
#
> “ It’s an old clock , ” I told them idiotically .
-# . W? D/P+ NSg/J NSg/VB+ . . ISg/#r+ VP NSg/IPl+ W? .
+# . W? D/P+ NSg/J NSg/VB+ . . ISg/#r+ VP NSg/IPl+ R .
>
#
> I think we all believed for a moment that it had smashed in pieces on the floor .
@@ -5601,7 +5601,7 @@
>
#
> “ I did , old sport , ” he said automatically , “ but I lost most of it in the big
-# . ISg/#r+ VPt . NSg/J+ NSg/VB+ . . NPr/ISg+ VP/J W? . . NSg/C/P ISg/#r+ VP/J NSg/I/J/R/Dq P NPr/ISg+ NPr/J/P D+ NSg/J+
+# . ISg/#r+ VPt . NSg/J+ NSg/VB+ . . NPr/ISg+ VP/J R . . NSg/C/P ISg/#r+ VP/J NSg/I/J/R/Dq P NPr/ISg+ NPr/J/P D+ NSg/J+
> panic — the panic of the war . ”
# NSg/VB/J+ . D NSg/VB/J P D+ N🅪Sg/VB+ . .
>
@@ -6371,7 +6371,7 @@
>
#
> “ You come to supper with me , ” said the lady enthusiastically . “ Both of you . ”
-# . ISgPl+ NSg/VBPp/P P NSg/VB P NPr/ISg+ . . VP/J D+ NPr/VB+ W? . . I/C/Dq P ISgPl+ . .
+# . ISgPl+ NSg/VBPp/P P NSg/VB P NPr/ISg+ . . VP/J D+ NPr/VB+ R . . I/C/Dq P ISgPl+ . .
>
#
> This included me . Mr . Sloane got to his feet .
@@ -8351,7 +8351,7 @@
>
#
> “ You must be crazy ! ” exclaimed Tom automatically .
-# . ISgPl+ NSg/VB NSg/VXB NSg/J . . VP/J NPr/VB+ W? .
+# . ISgPl+ NSg/VB NSg/VXB NSg/J . . VP/J NPr/VB+ R .
>
#
> Gatsby sprang to his feet , vivid with excitement .
@@ -8889,7 +8889,7 @@
> nearer , the hushed , intent faces of the people at the garage door made him
# NSg/JC . D VP/J . NSg/J+ NPl/V3 P D NPl/VB+ NSg/P D NSg/VB+ NSg/VB+ VB ISg+
> automatically put on the brakes .
-# W? NSg/VB J/P D NPl/V3+ .
+# R NSg/VB J/P D NPl/V3+ .
>
#
> “ We'll take a look , ” he said doubtfully , “ just a look . ”
@@ -9677,7 +9677,7 @@
> front , and following the Argonne battles he got his majority and the command of
# NSg/VB/J+ . VB/C Nᴹ/Vg/J/P D NPr NPl/V3+ NPr/ISg+ VB ISg/D$+ NSg+ VB/C D NSg/VB P
> the divisional machine - guns . After the armistice he tried frantically to get
-# D NSg/J NSg/VB+ . NPl/V3+ . P D NPr🅪 NPr/ISg+ VP/J W? P NSg/VB
+# D NSg/J NSg/VB+ . NPl/V3+ . P D NPr🅪 NPr/ISg+ VP/J R P NSg/VB
> home , but some complication or misunderstanding sent him to Oxford instead . He
# NSg/VB/J+ . NSg/C/P I/J/R/Dq N🅪Sg NPr/C N🅪Sg/Vg/J+ NSg/VB ISg+ P NPr+ R . NPr/ISg+
> was worried now — there was a quality of nervous despair in Daisy’s letters . She
@@ -9845,7 +9845,7 @@
>
#
> “ Don’t do it to - day , ” Gatsby answered . He turned to me apologetically . “ You
-# . VB NSg/VXB NPr/ISg+ P . NPr🅪+ . . NPr VP/J . NPr/ISg+ VP/J P NPr/ISg+ W? . . ISgPl+
+# . VB NSg/VXB NPr/ISg+ P . NPr🅪+ . . NPr VP/J . NPr/ISg+ VP/J P NPr/ISg+ R . . ISgPl+
> know , old sport , I’ve never used that pool all summer ? ”
# NSg/VB . NSg/J+ NSg/VB+ . W? R VP/J NSg/I/C/Ddem NSg/VB+ NSg/I/J/C/Dq NPr🅪/VB+ . .
>