Skip to content

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

feat: "there is" agreement (#3303)

Andrew Dunbar8c407ac37306
diff --git a/harper-core/default_config.json b/harper-core/default_config.json
index 47f038f4d..868e69d67 100644
--- a/harper-core/default_config.json
+++ b/harper-core/default_config.json
@@ -3644,6 +3644,13 @@
"label": "Code In Write In"
}
},
+ {
+ "Bool": {
+ "name": "ThereIsAgreement",
+ "state": true,
+ "label": "There Is Agreement"
+ }
+ },
{
"Bool": {
"name": "ASomeTime",
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index 63aef0496..d0ed50555 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -36268,7 +36268,7 @@ nondiscriminatory/J
nondramatic/J
nondrinker/NgS
nondrying/J
-none/~IN
+none/~I # remove `/N` since noun sense is rare/marginal
noneducational/J
noneffective/JN
nonelastic/J
diff --git a/harper-core/src/irregular_nouns.rs b/harper-core/src/irregular_nouns.rs
index 32b1f25fd..9e4d0c5ac 100644
--- a/harper-core/src/irregular_nouns.rs
+++ b/harper-core/src/irregular_nouns.rs
@@ -1,3 +1,4 @@
+use crate::CharStringExt;
use serde::Deserialize;
use std::sync::{Arc, LazyLock};
@@ -51,6 +52,13 @@ impl IrregularNouns {
(*NOUNS).clone()
}
+ pub fn get_plural_for_singular_chars(&self, singular: &[char]) -> Option<&str> {
+ self.nouns
+ .iter()
+ .find(|(sg, _)| singular.eq_str(sg))
+ .map(|(_, pl)| pl.as_str())
+ }
+
pub fn get_plural_for_singular(&self, singular: &str) -> Option<&str> {
self.nouns
.iter()
@@ -64,6 +72,13 @@ impl IrregularNouns {
.find(|(_, pl)| pl.eq_ignore_ascii_case(plural))
.map(|(sg, _)| sg.as_str())
}
+
+ pub fn get_singular_for_plural_chars(&self, plural: &[char]) -> Option<&str> {
+ self.nouns
+ .iter()
+ .find(|(_, pl)| plural.eq_str(pl))
+ .map(|(sg, _)| sg.as_str())
+ }
}
impl Default for IrregularNouns {
diff --git a/harper-core/src/lib.rs b/harper-core/src/lib.rs
index b1e845c5b..d3e0a4a3e 100644
--- a/harper-core/src/lib.rs
+++ b/harper-core/src/lib.rs
@@ -24,6 +24,7 @@ mod offsets;
pub mod parsers;
pub mod patterns;
mod punctuation;
+mod regular_nouns;
mod render_markdown;
mod span;
pub mod spell;
@@ -58,6 +59,7 @@ use linting::Lint;
pub use mask::{Mask, Masker, RegexMasker};
pub use number::{Number, OrdinalSuffix};
pub use punctuation::{Punctuation, Quote};
+pub use regular_nouns::{get_plurals, get_singulars};
pub use span::Span;
pub use sync::{LSend, Lrc};
pub use title_case::{make_title_case, make_title_case_str};
diff --git a/harper-core/src/linting/lint_group/mod.rs b/harper-core/src/linting/lint_group/mod.rs
index 466542dae..53005dc70 100644
--- a/harper-core/src/linting/lint_group/mod.rs
+++ b/harper-core/src/linting/lint_group/mod.rs
@@ -219,6 +219,7 @@ use super::the_my::TheMy;
use super::the_point_for::ThePointFor;
use super::the_proper_noun_possessive::TheProperNounPossessive;
use super::then_than::ThenThan;
+use super::there_is_agreement::ThereIsAgreement;
use super::theres::Theres;
use super::theses_these::ThesesThese;
use super::theyre_confusions::TheyreConfusions;
@@ -777,6 +778,13 @@ impl LintGroup {
out.add("SpellCheck", SpellCheck::new(dictionary.clone(), dialect));
out.config.set_rule_enabled("SpellCheck", true);
+ // Uses Dictionary, and Sentence rather than Chunk
+ out.add(
+ "ThereIsAgreement",
+ ThereIsAgreement::new(dictionary.clone()),
+ );
+ out.config.set_rule_enabled("ThereIsAgreement", true);
+
// Uses Sentence rather than Chunk
out.add("WebScraping", WebScraping::default());
out.config.set_rule_enabled("WebScraping", true);
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index a6406f671..10fde2cec 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -231,6 +231,7 @@ mod the_my;
mod the_point_for;
mod the_proper_noun_possessive;
mod then_than;
+mod there_is_agreement;
mod theres;
mod theses_these;
mod theyre_confusions;
diff --git a/harper-core/src/linting/there_is_agreement.rs b/harper-core/src/linting/there_is_agreement.rs
new file mode 100644
index 000000000..5c8f2bcf9
--- /dev/null
+++ b/harper-core/src/linting/there_is_agreement.rs
@@ -0,0 +1,1480 @@
+use crate::{
+ CharStringExt, Dialect, IrregularNouns, Lint, Lrc, Token, TokenStringExt,
+ expr::{Expr, FirstMatchOf, OwnedExprExt, SequenceExpr, SpelledNumberExpr},
+ indefinite_article::{InitialSound, starts_with_vowel},
+ linting::{
+ ExprLinter, LintKind, Suggestion,
+ expr_linter::{Sentence, followed_by_hyphen, followed_by_word},
+ },
+ regular_nouns,
+ spell::Dictionary,
+};
+
+#[derive(PartialEq, Debug)]
+enum Mismatch {
+ SingularBePluralNoun,
+ PluralBeSingularNoun,
+}
+
+impl Mismatch {
+ fn from_be(be: &[char]) -> Self {
+ if be.eq_any_ignore_ascii_case_str(&["are", "were"]) {
+ PluralBeSingularNoun
+ } else {
+ SingularBePluralNoun
+ }
+ }
+}
+use Mismatch::*;
+
+#[derive(PartialEq)]
+enum WordOrder {
+ Statement, // normal: there is, etc.
+ Question, // inverted: is there?, etc.
+}
+use WordOrder::*;
+
+#[derive(PartialEq)]
+enum Tense {
+ Present,
+ Past,
+}
+use Tense::*;
+
+pub struct ThereIsAgreement<D> {
+ expr: FirstMatchOf,
+ dict: D,
+}
+
+impl<D: Dictionary> ThereIsAgreement<D> {
+ pub fn new(dict: D) -> Self {
+ let plural_noun = Lrc::new(|t: &Token, _: &[char]| t.kind.is_plural_noun());
+
+ // reject singular nouns that are also: adjectives, "no", spelled numbers
+ // TODO but this rejects "problem"
+ // "two" etc. are sg. nouns even though they can also be plural quantifiers
+ let singular_noun = Lrc::new(SequenceExpr::default().then_singular_noun().and_not(
+ FirstMatchOf::new(vec![
+ Box::new(|t: &Token, s: &[char]| {
+ t.kind.is_adjective()
+ || t.get_ch(s)
+ .eq_any_ignore_ascii_case_chars(&[&['n', 'o'], &['n', 'o', 't']])
+ }),
+ Box::new(SpelledNumberExpr),
+ ]),
+ ));
+
+ let first_match_of: Vec<Box<dyn Expr>> = [
+ (SingularBePluralNoun, Statement, Present),
+ (SingularBePluralNoun, Statement, Past),
+ (SingularBePluralNoun, Question, Present),
+ (SingularBePluralNoun, Question, Past),
+ (PluralBeSingularNoun, Statement, Present),
+ (PluralBeSingularNoun, Statement, Past),
+ (PluralBeSingularNoun, Question, Present),
+ (PluralBeSingularNoun, Question, Past),
+ ]
+ .iter()
+ .map(|(mismatch, word_order, tense)| {
+ let be = match (mismatch, tense) {
+ (SingularBePluralNoun, Present) => "is",
+ (SingularBePluralNoun, Past) => "was",
+ (PluralBeSingularNoun, Present) => "are",
+ (PluralBeSingularNoun, Past) => "were",
+ };
+ let (first, second) = match word_order {
+ Statement => ("there", be),
+ Question => (be, "there"),
+ };
+
+ let seq = SequenceExpr::aco(first).t_ws().t_aco(second).t_ws();
+
+ (match mismatch {
+ SingularBePluralNoun => Box::new(seq.then(plural_noun.clone())),
+ PluralBeSingularNoun => Box::new(seq.then(singular_noun.clone())),
+ }) as Box<dyn Expr>
+ })
+ .chain(std::iter::once(Box::new(
+ SequenceExpr::fixed_phrase("there's ").then(plural_noun.clone()),
+ ) as Box<dyn Expr>))
+ .collect();
+
+ Self {
+ expr: FirstMatchOf::new(first_match_of),
+ dict,
+ }
+ }
+}
+
+impl<D: Dictionary> ExprLinter for ThereIsAgreement<D> {
+ type Unit = Sentence;
+
+ fn match_to_lint_with_context(
+ &self,
+ toks: &[Token],
+ src: &[char],
+ ctx: Option<(&[Token], &[Token])>,
+ ) -> Option<super::Lint> {
+ match_to_lint(&self.dict, toks, src, ctx)
+ }
+
+ fn expr(&self) -> &dyn Expr {
+ &self.expr
+ }
+
+ fn description(&self) -> &str {
+ "Checks for `is there` and its variants agreeing with singular vs plural subjects"
+ }
+}
+
+fn match_to_lint<D: Dictionary>(
+ dict: &D,
+ toks: &[Token],
+ src: &[char],
+ ctx: Option<(&[Token], &[Token])>,
+) -> Option<super::Lint> {
+ let first = toks[0].span.get_content(src);
+ let second = toks[2].span.get_content(src);
+
+ const BE_FORMS: &[&str] = &["is", "are", "was", "were"];
+
+ match (
+ first.starts_with_ignore_ascii_case_str("there"),
+ first.last(),
+ ) {
+ (false, _) if second.eq_str("there") => handle_question(toks, src, ctx, dict),
+ (true, Some(&'s')) => handle_theres(toks, src, ctx, dict),
+ (true, _) => handle_statement(toks, src, ctx, dict),
+ _ => None, // unreachable
+ }
+}
+
+// No need to allocate.
+// Only four input words are possible, but lettercase can vary.
+// Only grammatical number changes.
+fn get_new_be(orig_be: &[char]) -> &[char] {
+ let [first, second, ..] = orig_be else {
+ return orig_be;
+ };
+
+ match (first.to_ascii_lowercase(), second.to_ascii_lowercase()) {
+ ('i', 's') => &['a', 'r', 'e'],
+ ('a', 'r') => &['i', 's'],
+ ('w', 'a') => &['w', 'e', 'r', 'e'],
+ ('w', 'e') => &['w', 'a', 's'],
+ _ => orig_be,
+ }
+}
+
+type NounFormGetters<D> = (
+ fn(&[char]) -> Option<Vec<char>>,
+ fn(&D, &[char]) -> Vec<Vec<char>>,
+);
+
+// Returns zero or more noun forms.
+// Needs to allocate a vec for each noun and for the array of nouns.
+// Each noun will be accompanied by an appropriate indefinite article.
+// TODO does not yet handle words which take either/both "a"/"an"
+fn get_new_nouns<'a, D: Dictionary>(
+ dict: &D,
+ orig_noun: &'a [char],
+ mismatch_type: &Mismatch,
+) -> Vec<(Vec<char>, &'a [char])> {
+ let (irreg_func, reg_func): NounFormGetters<D> = match mismatch_type {
+ PluralBeSingularNoun => (get_irregular_plural, regular_nouns::get_plurals),
+ SingularBePluralNoun => (get_irregular_singular, regular_nouns::get_singulars),
+ };
+ let (irregular, regulars) = (irreg_func(orig_noun), reg_func(dict, orig_noun));
+
+ irregular
+ .into_iter()
+ .chain(regulars)
+ .collect::<Vec<_>>()
+ .into_iter()
+ .map(|n| {
+ let art = match starts_with_vowel(&n, Dialect::American) {
+ Some(InitialSound::Vowel) => &['a', 'n'][..],
+ Some(InitialSound::Consonant) => &['a'][..],
+ // Some(InitialSound::Either) => &[&['a'][..], &['a', 'n'][..]],
+ _ => &['a'][..],
+ };
+ (n, art)
+ })
+ .collect()
+}
+
+fn get_irregular_plural(singular: &[char]) -> Option<Vec<char>> {
+ IrregularNouns::curated()
+ .get_plural_for_singular_chars(singular)
+ .map(|s| s.chars().collect())
+}
+
+fn get_irregular_singular(plural: &[char]) -> Option<Vec<char>> {
+ IrregularNouns::curated()
+ .get_singular_for_plural_chars(plural)
+ .map(|s| s.chars().collect())
+}
+
+fn handle_statement<D: Dictionary>(
+ toks: &[Token],
+ src: &[char],
+ ctx: Option<(&[Token], &[Token])>,
+ dict: &D,
+) -> Option<Lint> {
+ // Don't proceed if the next token is a hyphen, indicating a compound.
+ // e.g. "function-like macros"
+ if followed_by_hyphen(ctx) {
+ return None;
+ }
+
+ // Or if the next word in a noun, also indicating a compound:
+ // e.g. "there are config errors"
+ if followed_by_word(ctx, |t| {
+ (t.kind.is_noun()
+ && !t.kind.is_verb_progressive_form()
+ && !t
+ .get_ch(src)
+ .eq_any_ignore_ascii_case_str(&["but", "in", "like"]))
+ // to allow "there are bug in ..." to be corrected
+ || t.get_ch(src).eq_any_ignore_ascii_case_str(&["and", "or"])
+ }) {
+ return None;
+ }
+
+ // NOTE - for a statement we only need to replace two words.
+ // NOTE - (there) "are man" -> "there is (a) man"
+ // -> "there are men"
+ let replacement_template = toks[2..=4].get_ch(src)?;
+
+ // tok 2 is form of "be": is are was were
+ // tok 4 is noun that doesn't agree in number with the form of "be"
+ let orig_be = toks[2].get_ch(src);
+ let orig_noun = toks[4].get_ch(src);
+
+ let mismatch_type = Mismatch::from_be(orig_be);
+
+ // fix 1 = change form of "be" to match the noun
+ // - suggestion is "corrected be" + noun
+ let new_be = get_new_be(orig_be);
+
+ // When PluralBeSingularNoun we need to look up the right
+ // indefinite article for the original noun
+ // and insert it before the noun (with a space between)
+ let mut replacement_value: Vec<char> = new_be.to_vec();
+
+ // Only add article and space for singular nouns
+ if matches!(mismatch_type, PluralBeSingularNoun) {
+ // get the indefinite article for the orig_noun
+ let article = match starts_with_vowel(orig_noun, Dialect::American) {
+ Some(InitialSound::Vowel) => &['a', 'n'][..],
+ Some(InitialSound::Consonant) => &['a'][..],
+ // TODO InitialSound::Either needs to return an array of ["a", "an"]
+ _ => &['\u{1F170}', '\u{fe0f}', '\u{1F170}', '\u{fe0f}'][..],
+ };
+ replacement_value.extend(&[' ']);
+ replacement_value.extend(article.iter());
+ }
+
+ replacement_value.push(' ');
+ replacement_value.extend(orig_noun.iter());
+
+ let be_suggestion =
+ Suggestion::replace_with_match_case(replacement_value, replacement_template);
+
+ // fix 2 = change noun to match the form of "be"
+ // - could be multiple
+ // - don't need a/an here because nouns are plural
+ let new_nouns = get_new_nouns(dict, orig_noun, &mismatch_type);
+
+ let article_noun_pairs = new_nouns
+ .iter()
+ .map(|(noun, article)| {
+ let mut result: Vec<char> = orig_be.to_vec();
+
+ if matches!(mismatch_type, SingularBePluralNoun) {
+ result.extend(&[' ']);
+ result.extend(article.iter());
+ }
+
+ result.extend(&[' ']);
+ result.extend(noun.iter());
+
+ result
+ })
+ .collect::<Vec<Vec<char>>>();
+
+ let noun_suggestions: Vec<Suggestion> = article_noun_pairs
+ .iter()
+ .map(|sug_repl_value| {
+ Suggestion::replace_with_match_case(sug_repl_value.to_vec(), replacement_template)
+ })
+ .collect();
+
+ Some(Lint {
+ span: toks[2..=4].span()?,
+ message: "There is disagreement in number between the verb and the noun.".to_string(),
+ suggestions: [vec![be_suggestion], noun_suggestions].concat(),
+ lint_kind: LintKind::Agreement,
+ ..Default::default()
+ })
+}
+
+fn handle_theres<D: Dictionary>(
+ toks: &[Token],
+ src: &[char],
+ _ctx: Option<(&[Token], &[Token])>,
+ dict: &D,
+) -> Option<Lint> {
+ // NOTE - for there's we only need to replace two words.
+ // NOTE - "there's men" -> there's a man
+ // -> there are men
+
+ let replacement_template = toks[0..=2].get_ch(src)?;
+
+ // tok 0 is "there's" (with various types of apostrophe character)
+ // tok 2 is noun that doesn't agree in number with "is" (the form of "be" encoded in "there's")
+ let orig_there_be = toks[0].span.get_content(src);
+ let orig_noun = toks[2].span.get_content(src);
+
+ let mismatch_type = SingularBePluralNoun;
+
+ // fix 1 = change "there's" to "there are" to match the noun
+ // - suggestion is "there are" + noun
+ let new_there_be = &['t', 'h', 'e', 'r', 'e', ' ', 'a', 'r', 'e'][..];
+
+ let replacement_value: Vec<char> = new_there_be
+ .iter()
+ .chain(&[' '])
+ .chain(orig_noun.iter())
+ .copied()
+ .collect();
+
+ let there_be_suggestion =
+ Suggestion::replace_with_match_case(replacement_value, replacement_template);
+
+ // fix 2
+ let new_nouns = get_new_nouns(dict, orig_noun, &mismatch_type);
+
+ let article_noun_pairs = new_nouns
+ .iter()
+ .map(|(noun, article)| {
+ let mut result: Vec<char> = orig_there_be.to_vec();
+
+ // there's is always SingularBePluralNoun
+ result.extend(&[' ']);
+ result.extend(article.iter());
+
+ result.extend(&[' ']);
+ result.extend(noun.iter());
+
+ result
+ })
+ .collect::<Vec<Vec<char>>>();
+
+ let noun_suggestions: Vec<Suggestion> = article_noun_pairs
+ .iter()
+ .map(|sug_repl_value| {
+ Suggestion::replace_with_match_case(sug_repl_value.to_vec(), replacement_template)
+ })
+ .collect();
+
+ Some(Lint {
+ span: toks[0..=2].span()?,
+ lint_kind: LintKind::Agreement,
+ suggestions: [vec![there_be_suggestion], noun_suggestions].concat(),
+ message: "`There's` means `there is`, which requires a singular noun.".to_string(),
+ ..Default::default()
+ })
+}
+
+fn handle_question<D: Dictionary>(
+ toks: &[Token],
+ src: &[char],
+ ctx: Option<(&[Token], &[Token])>,
+ dict: &D,
+) -> Option<Lint> {
+ // Don't proceed if the next token is a noun, indicating a compound:
+ // e.g. "there are config errors"
+ if followed_by_word(ctx, |t| {
+ t.kind.is_noun()
+ && !t.kind.is_verb_progressive_form()
+ && !t.get_ch(src).eq_any_ignore_ascii_case_str(&["in", "or"])
+ }) {
+ return None;
+ }
+
+ // NOTE - for a question we must replace three words!
+ // NOTE - "are there man" -> "is there (a) man"
+ // -> "are there men"
+ let replacement_template = toks[0..=4].get_ch(src)?;
+
+ // tok 0 is form of "be": is are was were
+ // tok 2 is "there"
+ // tok 4 is noun that doesn't agree in number with the form of "be"
+ let orig_be = toks[0].get_ch(src);
+ let orig_noun = toks[4].get_ch(src);
+
+ let mismatch_type = Mismatch::from_be(orig_be);
+
+ // fix 1 = change form of "be" to match the noun
+ // - suggestion is "corrected be" + "there" + noun
+ let new_be = get_new_be(orig_be);
+
+ let mut replacement_value: Vec<char> = new_be
+ .iter()
+ .chain(&[' ', 't', 'h', 'e', 'r', 'e'])
+ .copied()
+ .collect();
+
+ // Only add article and space for singular nouns
+ if matches!(mismatch_type, PluralBeSingularNoun) {
+ let article = match starts_with_vowel(orig_noun, Dialect::American) {
+ Some(InitialSound::Vowel) => &['a', 'n'][..],
+ Some(InitialSound::Consonant) => &['a'][..],
+ // TODO InitialSound::Either needs to return an array of ["a", "an"]
+ _ => &['\u{1F170}', '\u{fe0f}', '\u{1F170}', '\u{fe0f}'][..],
+ };
+ replacement_value.extend(&[' ']);
+ replacement_value.extend(article.iter());
+ }
+
+ replacement_value.extend(&[' ']);
+ replacement_value.extend(orig_noun.iter());
+
+ let be_suggestion =
+ Suggestion::replace_with_match_case(replacement_value, replacement_template);
+
+ // fix 2
+ let new_nouns = get_new_nouns(dict, orig_noun, &mismatch_type);
+ let article_noun_pairs = new_nouns
+ .iter()
+ .map(|(noun, article)| {
+ let mut result: Vec<char> = orig_be
+ .iter()
+ .chain(&[' ', 't', 'h', 'e', 'r', 'e'])
+ .copied()
+ .collect();
+
+ // Only add article and space for singular nouns
+ if matches!(mismatch_type, SingularBePluralNoun) {
+ result.extend(&[' ']);
+ result.extend(article.iter());
+ }
+
+ result.extend(&[' ']);
+ result.extend(noun.iter());
+
+ result
+ })
+ .collect::<Vec<_>>();
+
+ let noun_suggestions = article_noun_pairs
+ .iter()
+ .map(|replacement_value| {
+ Suggestion::replace_with_match_case(replacement_value.to_vec(), replacement_template)
+ })
+ .collect::<Vec<_>>();
+
+ Some(Lint {
+ span: toks[0..=4].span()?,
+ lint_kind: LintKind::Agreement,
+ suggestions: [vec![be_suggestion], noun_suggestions].concat(),
+ message: "There is disagreement in number between the verb and the noun.".to_string(),
+ ..Default::default()
+ })
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::{
+ linting::tests::{
+ assert_good_and_bad_suggestions, assert_no_lints, assert_suggestion_result,
+ },
+ spell::FstDictionary,
+ };
+
+ use super::ThereIsAgreement;
+
+ // basic functionality
+
+ #[test]
+ fn statement_present_pl_regular() {
+ assert_good_and_bad_suggestions(
+ "there is things",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["there are things", "there is a thing"],
+ &[],
+ );
+ }
+
+ #[test]
+ fn statement_present_sg_irregular() {
+ assert_good_and_bad_suggestions(
+ "there are person",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["there are people", "there is a person"],
+ &[],
+ );
+ }
+
+ #[test]
+ fn statement_present_theres_pl() {
+ assert_good_and_bad_suggestions(
+ "there's secrets",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["there are secrets", "there's a secret"],
+ &[],
+ );
+ }
+
+ #[test]
+ fn statement_past_pl_vowel() {
+ assert_good_and_bad_suggestions(
+ "there was ideas",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["there were ideas", "there was an idea"],
+ &[],
+ );
+ }
+
+ #[test]
+ fn statement_past_sg() {
+ assert_good_and_bad_suggestions(
+ "there were child",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["there were children", "there was a child"],
+ &[],
+ );
+ }
+
+ #[test]
+ // NOTE suggests "mans" and "manes" due to how the dictionary & annotations work
+ fn question_pres_sg() {
+ assert_good_and_bad_suggestions(
+ "are there man",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["are there men", "is there a man"],
+ &[],
+ );
+ }
+
+ #[test]
+ fn question_pres_pl() {
+ assert_good_and_bad_suggestions(
+ "is there women",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["are there women", "is there a woman"],
+ &[],
+ );
+ }
+
+ #[test]
+ fn question_past_sg() {
+ assert_good_and_bad_suggestions(
+ "were there cow",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["were there cows", "was there a cow"],
+ &[],
+ );
+ }
+
+ #[test]
+ fn question_past_pl() {
+ assert_good_and_bad_suggestions(
+ "were there elephant",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &["were there elephants", "was there an elephant"],
+ &[],
+ );
+ }
+
+ #[test]
+ fn dont_flag_there_are_hyphenated_compound_starts_singular() {
+ assert_no_lints(
+ "there are function-like macros",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn dont_flag_there_are_open_compound_starts_singular() {
+ assert_no_lints(
+ "there are config errors",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn a_or_an_depends_on_dialect_herb() {
+ assert_good_and_bad_suggestions(
+ "there's herbs.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there are herbs.",
+ // "there'ss a herb.", // TODO: This module does not yet accept a `Dialect`, `American` is hard-coded for now.
+ "there's an herb.",
+ ],
+ &[],
+ )
+ }
+
+ #[test]
+ fn a_or_an_depends_on_dialect_hotel() {
+ assert_good_and_bad_suggestions(
+ "There are hotel.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "There are hotels.",
+ "There is a hotel.",
+ // "There is an hotel.", // TODO: Dialect, preference, or both?
+ ],
+ &[],
+ )
+ }
+
+ // Real-world tests
+
+ // there is plural: fix
+
+ #[test]
+ fn fix_there_is_errors() {
+ assert_good_and_bad_suggestions(
+ "Hi, when I make the code, there is errors",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Hi, when I make the code, there are errors",
+ "Hi, when I make the code, there is an error",
+ ],
+ &["Hi, when I make the code, there is a error"],
+ );
+ }
+
+ #[test]
+ fn fix_there_is_warnings() {
+ assert_good_and_bad_suggestions(
+ "There is warnings from kotlin and dart, as reference: Elvis operator (?:) always returns the left operand of non-nullable type String.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "There are warnings from kotlin and dart, as reference: Elvis operator (?:) always returns the left operand of non-nullable type String.",
+ "There is a warning from kotlin and dart, as reference: Elvis operator (?:) always returns the left operand of non-nullable type String.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_is_problems() {
+ assert_good_and_bad_suggestions(
+ "Problem is that if there is a project that has a csproj file, then there is problems with the history folder.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Problem is that if there is a project that has a csproj file, then there are problems with the history folder.",
+ "Problem is that if there is a project that has a csproj file, then there is a problem with the history folder.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ #[ignore = "`replace_with_match_case` matching case char-by-char causes the wrong letters to be uppercased"]
+ fn fix_there_is_commands() {
+ assert_good_and_bad_suggestions(
+ "Additionally if there is Commands that can be used on multiple Resources at the same time.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Additionally if there are Commands that can be used on multiple Resources at the same time.",
+ "Additionally if there is a Command that can be used on multiple Resources at the same time.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_is_values() {
+ assert_suggestion_result(
+ "This mean there would not be a single cache, but as many caches as there is values for the second argument.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ "This mean there would not be a single cache, but as many caches as there are values for the second argument.",
+ );
+ }
+
+ #[test]
+ fn fix_there_is_strings() {
+ assert_good_and_bad_suggestions(
+ "I can image other cases (tools different from SPSS) in which there is strings in both sides of the dictionary",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "I can image other cases (tools different from SPSS) in which there are strings in both sides of the dictionary",
+ "I can image other cases (tools different from SPSS) in which there is a string in both sides of the dictionary",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_is_things() {
+ assert_good_and_bad_suggestions(
+ "even though we can check whether there is things running in Node, we can not do it for Chromium's message loops",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "even though we can check whether there are things running in Node, we can not do it for Chromium's message loops",
+ "even though we can check whether there is a thing running in Node, we can not do it for Chromium's message loops",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_is_people() {
+ // TODO `assert_good_and_bad_suggestions`` fails with more than two correct answers because
+ // TODO it hasn't been converted to the new logic in `assert_suggestion_result`
+ // assert_good_and_bad_suggestions(
+ // "there is people making projects, there is people doing tutorials",
+ // ThereIsAgreement::new(FstDictionary::curated(),
+ // &[
+ // "there are people making projects, there are people doing tutorials",
+ // "there is a person making projects, there is a person doing tutorials",
+ // ],
+ // &[],
+ // );
+ assert_suggestion_result(
+ "there is people making projects, there is people doing tutorials",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ "there are people making projects, there are people doing tutorials",
+ );
+ assert_suggestion_result(
+ "there is people making projects, there is people doing tutorials",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ "there is a person making projects, there is a person doing tutorials",
+ );
+ }
+
+ #[test]
+ fn fix_there_is_instructions() {
+ assert_good_and_bad_suggestions(
+ "I am just wondering if there is instructions somewhere for handling deep linking while using Redux.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "I am just wondering if there are instructions somewhere for handling deep linking while using Redux.",
+ "I am just wondering if there is an instruction somewhere for handling deep linking while using Redux.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_is_packages() {
+ assert_suggestion_result(
+ "if there is packages that handle such protocols installed",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ "if there are packages that handle such protocols installed",
+ );
+ }
+
+ // there is plural: don't flag
+
+ #[test]
+ // NOTE: This actually does pass because "who" is marked as a noun
+ // NOTE: because the dictionary is case-folded and "WHO" is a proper noun.
+ #[ignore = "TODO: abort if next word is a relative pronoun like `who`"]
+ fn dont_flag_there_is_people_who_have_done_xyz() {
+ assert_no_lints(
+ "The main expectation there is people who have a deprecated app installed will then get an error if it's disabled",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ #[ignore = "TODO: abort if next token is `/`"]
+ fn dont_flag_there_is_packages_part_of_dir() {
+ assert_no_lints(
+ "For example there is packages/vite/src/node , but no packages/vite/src/deno",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ // there are singular: fix
+
+ #[test]
+ fn fix_there_are_bug() {
+ assert_good_and_bad_suggestions(
+ "there are bug in svelte 3.0 that axios from 0.22.0 version undefined",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there is a bug in svelte 3.0 that axios from 0.22.0 version undefined",
+ "there are bugs in svelte 3.0 that axios from 0.22.0 version undefined",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_are_description() {
+ assert_good_and_bad_suggestions(
+ "there are description regarding thread safety in zmq document.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there is a description regarding thread safety in zmq document.",
+ "there are descriptions regarding thread safety in zmq document.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_are_issue() {
+ assert_good_and_bad_suggestions(
+ "Seems like if there are issue with OpenAI, it is still trying to call chat completion and giving type error.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Seems like if there are issues with OpenAI, it is still trying to call chat completion and giving type error.",
+ "Seems like if there is an issue with OpenAI, it is still trying to call chat completion and giving type error.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ #[ignore = "TODO: 'problem' is being rejected as an adjective as well as a singular noun"]
+ fn fix_there_are_problem() {
+ assert_good_and_bad_suggestions(
+ "There are problem with official serving docker image gpu version",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "There is a problem with official serving docker image gpu version",
+ "There are problems with official serving docker image gpu version",
+ ],
+ &[],
+ );
+ }
+
+ // there are singular: don't flag
+
+ #[test]
+ fn dont_flag_there_are_dep_conflicts() {
+ assert_no_lints(
+ "Wrong advice when there are dependency conflicts",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn dont_flag_there_are_dep_errs() {
+ assert_no_lints(
+ "If there are dependency errors they will be immediately logged out to you.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ #[ignore = "'definition syntax' looks singular but the full np is the plural 'definition syntax errors'"]
+ fn dont_flag_there_are_def_syntax_errs() {
+ assert_no_lints(
+ "New Campaign Properties dialog loses changes if there are definition syntax errors",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn dont_flag_there_are_description_and_instruction_keys() {
+ assert_no_lints(
+ "There are description and instruction keys for the classes.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn dont_flag_there_are_function_like() {
+ assert_no_lints(
+ "clang-format indents class member functions oddly if there are function-like macro invocations",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ // there was pl: fix
+
+ #[test]
+ fn fix_there_was_configs() {
+ assert_good_and_bad_suggestions(
+ "I did see that there was configs for it before but it isn't in the configs anymore.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "I did see that there were configs for it before but it isn't in the configs anymore.",
+ "I did see that there was a config for it before but it isn't in the configs anymore.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_was_examples() {
+ assert_good_and_bad_suggestions(
+ "It would be awesome if there was examples on how to include inline citations",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "It would be awesome if there were examples on how to include inline citations",
+ "It would be awesome if there was an example on how to include inline citations",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_was_functions() {
+ assert_good_and_bad_suggestions(
+ "I noticed in the AXP2101_Class for the unified library that there was functions like \"isPekeyShortPressIrq()\"",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "I noticed in the AXP2101_Class for the unified library that there were functions like \"isPekeyShortPressIrq()\"",
+ "I noticed in the AXP2101_Class for the unified library that there was a function like \"isPekeyShortPressIrq()\"",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_was_issues() {
+ assert_good_and_bad_suggestions(
+ "Restored to a Snapshot, but there was issues with Hyprland.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Restored to a Snapshot, but there were issues with Hyprland.",
+ "Restored to a Snapshot, but there was an issue with Hyprland.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_was_settings() {
+ assert_good_and_bad_suggestions(
+ "I also tried creating a fresh page on the same site, and there was settings but only 2 pages of settings",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "I also tried creating a fresh page on the same site, and there were settings but only 2 pages of settings",
+ "I also tried creating a fresh page on the same site, and there was a setting but only 2 pages of settings",
+ ],
+ &[],
+ );
+ }
+
+ // there were sg: fix
+
+ #[test]
+ fn fix_there_were_function() {
+ assert_good_and_bad_suggestions(
+ "Instead, it would be helpful if there were function in the autoloader capable of taking the a list of names of packages to enable.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Instead, it would be helpful if there were functions in the autoloader capable of taking the a list of names of packages to enable.",
+ "Instead, it would be helpful if there was a function in the autoloader capable of taking the a list of names of packages to enable.",
+ // TODO we don't support subjunctive "were" in contexts after "if"
+ // "Instead, it would be helpful if there were a function in the autoloader capable of taking the a list of names of packages to enable.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_were_hint() {
+ assert_good_and_bad_suggestions(
+ "there were hint that this could break the build",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there were hints that this could break the build",
+ "there was a hint that this could break the build",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_there_were_issue() {
+ assert_good_and_bad_suggestions(
+ "there were issue with using venv and it was pulled",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there were issues with using venv and it was pulled",
+ "there was an issue with using venv and it was pulled",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ #[ignore = "TODO: 'problem' is being rejected as an adjective as well as a singular noun"]
+ fn fix_there_were_problem_about() {
+ assert_good_and_bad_suggestions(
+ "there were problem about version but this error is solved by correcting version in these files",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there were problems about version but this error is solved by correcting version in these files",
+ "there was a problem about version but this error is solved by correcting version in these files",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ #[ignore = "TODO: 'problem' is being rejected as an adjective as well as a singular noun"]
+ fn fix_there_were_problem_with() {
+ assert_good_and_bad_suggestions(
+ "there were problem with page alignment crossing",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there were problems with page alignment crossing",
+ "there was a problem with page alignment crossing",
+ ],
+ &[],
+ );
+ }
+
+ // there were sg: don't flag
+
+ #[test]
+ // "two" is a technically a singular noun, but we avoid flagging numbers
+ fn dont_flag_alice_there_were_two() {
+ assert_no_lints(
+ "This time there were two little shrieks, and more sounds of broken glass.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn dont_flag_gatsby_there_were_twinkle_bells() {
+ assert_no_lints(
+ "When he realized what I was talking about, that there were twinkle-bells of sunshine in the room, he smiled like a weather man",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ #[ignore = "We can't detect first name + surname, especially for rare surnames like 'Waize'"]
+ fn dont_flag_gatsby_there_were_a_and_b() {
+ assert_no_lints(
+ "Of theatrical people there were Gus Waize and Horace O’Donavan and Lester Myer and George Duckweed and Francis",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ // is there plural
+
+ #[test]
+ fn fix_is_there_apps() {
+ assert_good_and_bad_suggestions(
+ "Ok, but is there apps that actually do that?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Ok, but are there apps that actually do that?",
+ "Ok, but is there an app that actually do that?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_is_there_ideas() {
+ assert_suggestion_result(
+ "Is there ideas to make regular page to listen for api (POST/PUT/.. etc requests)",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ "Are there ideas to make regular page to listen for api (POST/PUT/.. etc requests)",
+ );
+ }
+
+ #[test]
+ fn fix_is_there_people() {
+ assert_suggestion_result(
+ "please guys tell me, is there people really making money with bot?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ "please guys tell me, are there people really making money with bot?",
+ );
+ }
+
+ #[test]
+ fn fix_is_there_solutions() {
+ assert_good_and_bad_suggestions(
+ "Run-as binary without the suid bit set, is there solutions?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Run-as binary without the suid bit set, are there solutions?",
+ "Run-as binary without the suid bit set, is there a solution?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_is_there_things() {
+ assert_suggestion_result(
+ "is there things you could change to make it a more general product",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ "are there things you could change to make it a more general product",
+ );
+ }
+
+ #[test]
+ fn fix_is_there_tools() {
+ assert_good_and_bad_suggestions(
+ "Is there tools or documentation how to recover / rebuild /run fsck on the failed replicas.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Are there tools or documentation how to recover / rebuild /run fsck on the failed replicas.",
+ "Is there a tool or documentation how to recover / rebuild /run fsck on the failed replicas.",
+ ],
+ &[],
+ );
+ }
+
+ // are there singular: fix
+
+ #[test]
+ #[ignore = "TODO: 'problem' is being rejected as an adjective as well as a singular noun"]
+ fn fix_are_there_problem() {
+ assert_good_and_bad_suggestions(
+ "Is it just the namespace or are there problem in the use statements as well?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Is it just the namespace or are there problems in the use statements as well?",
+ "Is it just the namespace or is there a problem in the use statements as well?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_are_there_solution() {
+ assert_good_and_bad_suggestions(
+ "Are there solution for making lsws using h2 protocol in client browsers?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Are there solutions for making lsws using h2 protocol in client browsers?",
+ "Is there a solution for making lsws using h2 protocol in client browsers?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_are_there_solution_slash_workaround() {
+ assert_good_and_bad_suggestions(
+ "are there solution/workaround ?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ // TODO the ideal fix pluralizes each word separated by `/`
+ // "are there solutions/workarounds ?",
+ "are there solutions/workaround ?",
+ "is there a solution/workaround ?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_are_there_concept() {
+ assert_good_and_bad_suggestions(
+ "So, what is a external interface in C++? are there concept of interface in C++?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "So, what is a external interface in C++? are there concepts of interface in C++?",
+ "So, what is a external interface in C++? is there a concept of interface in C++?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_are_there_object() {
+ assert_good_and_bad_suggestions(
+ "He check are there object with same id, if there is no object with same id he creates new and add to array",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "He check are there objects with same id, if there is no object with same id he creates new and add to array",
+ "He check is there an object with same id, if there is no object with same id he creates new and add to array",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ #[ignore = "variable is being rejected as an adjective as well as a singular noun"]
+ fn fix_are_there_variable() {
+ assert_good_and_bad_suggestions(
+ "Are there variable in side it or is it some sort of dataset?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Are there variables in side it or is it some sort of dataset?",
+ "Is there a variable in side it or is it some sort of dataset?",
+ ],
+ &[],
+ );
+ }
+
+ // are there singular: don't flag
+
+ #[test]
+ fn ignore_are_there_answer_generation_errors() {
+ assert_no_lints(
+ "Are there Answer Generation Errors?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn ignore_are_there_application_objects() {
+ assert_no_lints(
+ "Are there application objects assigned to non-existent sites",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn ignore_are_there_code_files() {
+ assert_no_lints(
+ "Why are there code files more than 10k lines long?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn ignore_are_there_error_logs() {
+ assert_no_lints(
+ "Are there error logs in your worker when flows fail?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn ignore_are_there_tool_specific() {
+ assert_no_lints(
+ "Are there tool specific constraints for RM tool exchange for EA?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ // was there plural: fix
+
+ #[test]
+ fn fix_was_there_bugs() {
+ assert_good_and_bad_suggestions(
+ "Was there bugs, and goofed-up quests?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Were there bugs, and goofed-up quests?",
+ "Was there a bug, and goofed-up quests?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_was_there_hints() {
+ assert_good_and_bad_suggestions(
+ "Was there hints in the game that points you to it?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Were there hints in the game that points you to it?",
+ "Was there a hint in the game that points you to it?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_was_there_issues() {
+ assert_good_and_bad_suggestions(
+ "I saw you closed that PR, was there issues getting it merged upstream?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "I saw you closed that PR, were there issues getting it merged upstream?",
+ "I saw you closed that PR, was there an issue getting it merged upstream?",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_was_there_problems() {
+ assert_good_and_bad_suggestions(
+ "Was there problems with other files that you had written to the SD card (PRG/CRT)?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Were there problems with other files that you had written to the SD card (PRG/CRT)?",
+ "Was there a problem with other files that you had written to the SD card (PRG/CRT)?",
+ ],
+ &[],
+ );
+ }
+
+ // was there plural: don't flag
+
+ #[test]
+ fn dont_flag_last_time_i_was_there() {
+ assert_no_lints(
+ "Last time I was there flags were on almost every house or fence.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ #[ignore = "Harper cannot detect this construction"]
+ fn dont_flag_the_grate_was_there() {
+ assert_no_lints(
+ "Saying the grate was there helps him avoid a lawsuit.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn dont_flag_when_he_was_there() {
+ assert_no_lints(
+ "When he was there tips were going way, way up.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ // were there sg: fix
+
+ #[test]
+ fn were_there_description() {
+ assert_good_and_bad_suggestions(
+ "Were there pictures of the Primarchs around before then? Were there description?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Were there pictures of the Primarchs around before then? Were there descriptions?",
+ "Were there pictures of the Primarchs around before then? Was there a description?",
+ ],
+ &[],
+ );
+ }
+
+ // were there sg: don't flag
+
+ #[test]
+ fn font_flag_were_there_bomb_drills() {
+ assert_no_lints(
+ "Were there bomb drills in school?",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn dont_flag_were_there_set_rules() {
+ assert_no_lints(
+ "For instance, were there set rules as to the funds that candidates would have to have acquired",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn dont_flag_were_there_tour_buses() {
+ assert_no_lints(
+ "Were there tour buses and different hotels and parties each night? Yep.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ // there's plural
+
+ #[test]
+ fn fix_theres_children() {
+ assert_good_and_bad_suggestions(
+ "now, check whether there's children",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "now, check whether there's a child",
+ "now, check whether there are children",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_theres_ideas() {
+ assert_good_and_bad_suggestions(
+ "there's ideas how it should behave for some media etc.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there's an idea how it should behave for some media etc.",
+ "there are ideas how it should behave for some media etc.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_theres_people() {
+ assert_good_and_bad_suggestions(
+ "Currently there's people helping out, and it's fairly easy to find someone if you need something.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "Currently there are people helping out, and it's fairly easy to find someone if you need something.",
+ "Currently there's a person helping out, and it's fairly easy to find someone if you need something.",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_theres_problems() {
+ assert_good_and_bad_suggestions(
+ "there's problems when using WSL::Ubuntu",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "there are problems when using WSL::Ubuntu",
+ "there's a problem when using WSL::Ubuntu",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_theres_things() {
+ assert_good_and_bad_suggestions(
+ "If there's things you love/hate about Vidstack please let us know",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "If there are things you love/hate about Vidstack please let us know",
+ "If there's a thing you love/hate about Vidstack please let us know",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_theres_urls() {
+ assert_good_and_bad_suggestions(
+ "so you're not suprised if there's urls missing or your data isn't being refreshed daily",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ &[
+ "so you're not suprised if there are urls missing or your data isn't being refreshed daily",
+ "so you're not suprised if there's a url missing or your data isn't being refreshed daily",
+ // "so you're not suprised if there's an url missing or your data isn't being refreshed daily",
+ ],
+ &[],
+ );
+ }
+
+ #[test]
+ fn fix_browser_console_3066() {
+ assert_no_lints(
+ "Finally, I’ve checked the browser’s developer console for any JavaScript errors, but there are none.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn fix_there_was_none_3066() {
+ assert_no_lints(
+ "There were none.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+
+ #[test]
+ fn fix_none_related_to_3066() {
+ assert_no_lints(
+ "I’ve inspected the browser console for JavaScript errors, and there are none related to WooCommerce or the product variation functionality.",
+ ThereIsAgreement::new(FstDictionary::curated()),
+ );
+ }
+}
diff --git a/harper-core/src/regular_nouns.rs b/harper-core/src/regular_nouns.rs
new file mode 100644
index 000000000..9b2fd793f
--- /dev/null
+++ b/harper-core/src/regular_nouns.rs
@@ -0,0 +1,283 @@
+use crate::{CharStringExt, spell::Dictionary};
+
+/// Get all valid plural forms using regular patterns, validated against dictionary
+/// Returns vector of suggestions that are confirmed to be plural nouns
+pub fn get_plurals(dict: &impl Dictionary, singular: &[char]) -> Vec<Vec<char>> {
+ // Filter candidates by dictionary validation
+ get_plural_candidates(singular)
+ .into_iter()
+ .filter(|candidate| {
+ dict.get_word_metadata(candidate)
+ .is_some_and(|md| md.is_plural_noun())
+ })
+ .collect()
+}
+
+/// Get all valid singular forms using regular patterns, validated against dictionary
+/// Returns vector of suggestions that are confirmed to be singular nouns
+pub fn get_singulars(dict: &impl Dictionary, plural: &[char]) -> Vec<Vec<char>> {
+ // Filter candidates by dictionary validation
+ get_singular_candidates(plural)
+ .into_iter()
+ .filter(|candidate| {
+ dict.get_word_metadata(candidate)
+ .is_some_and(|md| md.is_singular_noun())
+ })
+ .collect()
+}
+
+fn get_plural_candidates(singular: &[char]) -> Vec<Vec<char>> {
+ let mut candidates = Vec::new();
+
+ if singular.is_empty() {
+ return candidates;
+ }
+
+ // Handle -y -> -ies pattern (e.g., "city" -> "cities")
+ if singular.ends_with_ignore_ascii_case_chars(&['y']) && singular.len() > 1 {
+ let mut plural = singular[..singular.len() - 1].to_vec();
+ plural.extend(['i', 'e', 's']);
+ candidates.push(plural);
+ }
+
+ // Handle -fe -> -ves pattern (e.g., "wife" -> "wives")
+ if singular.ends_with_ignore_ascii_case_chars(&['f', 'e']) {
+ let mut plural = singular[..singular.len() - 2].to_vec();
+ plural.extend(['v', 'e', 's']);
+ candidates.push(plural);
+ }
+
+ // Handle -f -> -ves pattern (e.g., "wolf" -> "wolves")
+ if singular.ends_with_ignore_ascii_case_chars(&['f']) {
+ let mut plural = singular[..singular.len() - 1].to_vec();
+ plural.extend(['v', 'e', 's']);
+ candidates.push(plural);
+ }
+
+ // Defaults: add -s and -es
+ let mut plural_s = singular.to_vec();
+ plural_s.push('s');
+ candidates.push(plural_s);
+
+ let mut plural_es = singular.to_vec();
+ plural_es.extend(['e', 's']);
+ candidates.push(plural_es);
+
+ candidates
+}
+
+fn get_singular_candidates(plural: &[char]) -> Vec<Vec<char>> {
+ let mut candidates = Vec::new();
+
+ if plural.is_empty() {
+ return candidates;
+ }
+
+ // Handle -ies -> -y pattern (e.g., "cities" -> "city")
+ if plural.ends_with_ignore_ascii_case_chars(&['i', 'e', 's']) {
+ let mut singular = plural[..plural.len() - 3].to_vec();
+ singular.push('y');
+ candidates.push(singular);
+ }
+
+ // Handle -ves -> -fe and -ves -> -f patterns (e.g., "wives" -> "wife", "wolves" -> "wolf")
+ if plural.ends_with_ignore_ascii_case_chars(&['v', 'e', 's']) {
+ let mut singular_fe = plural[..plural.len() - 3].to_vec();
+ singular_fe.extend(['f', 'e']);
+ candidates.push(singular_fe);
+
+ let mut singular_f = plural[..plural.len() - 3].to_vec();
+ singular_f.push('f');
+ candidates.push(singular_f);
+ }
+
+ // Handle -es -> (remove es) pattern for -s, -sh, -ch, -x, -z endings
+ if plural.ends_with_ignore_ascii_case_chars(&['e', 's']) && plural.len() > 2 {
+ let singular = plural[..plural.len() - 2].to_vec();
+ candidates.push(singular);
+ }
+
+ // Default: remove trailing -s (but only if it's a single s)
+ if plural.ends_with_ignore_ascii_case_chars(&['s'])
+ && !plural.ends_with_ignore_ascii_case_chars(&['s', 's'])
+ {
+ let singular = plural[..plural.len() - 1].to_vec();
+ candidates.push(singular);
+ }
+
+ candidates
+}
+
+#[cfg(test)]
+mod tests {
+ use super::{get_plurals, get_singulars};
+ use crate::spell::FstDictionary;
+
+ #[test]
+ fn test_regular_plurals_add_s() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['c', 'a', 't']);
+ assert!(plurals.contains(&['c', 'a', 't', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_regular_plurals_y_to_ies() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['c', 'i', 't', 'y']);
+ assert!(plurals.contains(&['c', 'i', 't', 'i', 'e', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_regular_plurals_vowel_y_adds_s() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['b', 'o', 'y']);
+ assert!(plurals.contains(&['b', 'o', 'y', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_regular_plurals_fe_to_ves() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['w', 'i', 'f', 'e']);
+ assert!(plurals.contains(&['w', 'i', 'v', 'e', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_regular_plurals_f_to_ves() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['w', 'o', 'l', 'f']);
+ assert!(plurals.contains(&['w', 'o', 'l', 'v', 'e', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_regular_plurals_es_endings() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['b', 'u', 's']);
+ assert!(plurals.contains(&['b', 'u', 's', 'e', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_regular_plurals_o_to_oes() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['p', 'o', 't', 'a', 't', 'o']);
+ assert!(plurals.contains(&['p', 'o', 't', 'a', 't', 'o', 'e', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_regular_plurals_vowel_o_adds_s() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['r', 'a', 'd', 'i', 'o']);
+ assert!(plurals.contains(&['r', 'a', 'd', 'i', 'o', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_single_letter_words() {
+ // Single letters won't generate valid plurals in the dictionary
+ let plurals = get_plurals(&FstDictionary::curated(), &['a']);
+ assert!(plurals.is_empty());
+
+ let singulars = get_singulars(&FstDictionary::curated(), &['s']);
+ // Single 's' will be treated as a plural and try to remove the 's', leaving empty
+ assert!(singulars.is_empty());
+ }
+
+ #[test]
+ fn test_empty_string() {
+ let plurals = get_plurals(&FstDictionary::curated(), &[]);
+ assert!(plurals.is_empty());
+
+ let singulars = get_singulars(&FstDictionary::curated(), &[]);
+ assert!(singulars.is_empty());
+ }
+
+ #[test]
+ fn test_chars_versions() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['c', 'i', 't', 'y']);
+ assert!(plurals.contains(&['c', 'i', 't', 'i', 'e', 's'].to_vec()));
+
+ let singulars = get_singulars(&FstDictionary::curated(), &['c', 'i', 't', 'i', 'e', 's']);
+ assert!(singulars.contains(&['c', 'i', 't', 'y'].to_vec()));
+ }
+
+ #[test]
+ fn test_singular_from_plural_remove_s() {
+ let singulars = get_singulars(&FstDictionary::curated(), &['c', 'a', 't', 's']);
+ assert!(singulars.contains(&['c', 'a', 't'].to_vec()));
+ }
+
+ #[test]
+ fn test_singular_from_plural_ies_to_y() {
+ let singulars = get_singulars(&FstDictionary::curated(), &['c', 'i', 't', 'i', 'e', 's']);
+ assert!(singulars.contains(&['c', 'i', 't', 'y'].to_vec()));
+ }
+
+ #[test]
+ fn test_singular_from_plural_ves_to_fe() {
+ let singulars = get_singulars(&FstDictionary::curated(), &['w', 'i', 'v', 'e', 's']);
+ assert!(singulars.contains(&['w', 'i', 'f', 'e'].to_vec()));
+ }
+
+ #[test]
+ fn test_singular_from_plural_ves_to_f() {
+ let singulars = get_singulars(&FstDictionary::curated(), &['w', 'o', 'l', 'v', 'e', 's']);
+ assert!(singulars.contains(&['w', 'o', 'l', 'f'].to_vec()));
+ }
+
+ #[test]
+ fn test_singular_from_plural_es_removal() {
+ let singulars = get_singulars(
+ &FstDictionary::curated(),
+ &['c', 'l', 'a', 's', 's', 'e', 's'],
+ );
+ assert!(singulars.contains(&['c', 'l', 'a', 's', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_singular_from_plural_oes_to_o() {
+ let singulars = get_singulars(
+ &FstDictionary::curated(),
+ &['p', 'o', 't', 'a', 't', 'o', 'e', 's'],
+ );
+ assert!(singulars.contains(&['p', 'o', 't', 'a', 't', 'o'].to_vec()));
+ }
+
+ #[test]
+ fn test_empty_string_plural() {
+ let plurals = get_plurals(&FstDictionary::curated(), &[]);
+ assert!(plurals.is_empty());
+ }
+
+ #[test]
+ fn test_empty_string_singular() {
+ let singulars = get_singulars(&FstDictionary::curated(), &[]);
+ assert!(singulars.is_empty());
+ }
+
+ #[test]
+ fn test_case_insensitive_plurals() {
+ // Lowercase input produces lowercase output
+ let lowercase_city: Vec<char> = "city".chars().collect();
+ let plurals = get_plurals(&FstDictionary::curated(), &lowercase_city);
+ assert!(plurals.contains(&['c', 'i', 't', 'i', 'e', 's'].to_vec()));
+
+ // Mixed case input: stem case preserved, suffix lowercase
+ let mixed_city: Vec<char> = "City".chars().collect();
+ let plurals = get_plurals(&FstDictionary::curated(), &mixed_city);
+ assert!(plurals.contains(&['C', 'i', 't', 'i', 'e', 's'].to_vec()));
+ }
+
+ #[test]
+ fn test_case_insensitive_singulars() {
+ // Lowercase input produces lowercase output
+ let lowercase_cities: Vec<char> = "cities".chars().collect();
+ let singulars = get_singulars(&FstDictionary::curated(), &lowercase_cities);
+ assert!(singulars.contains(&['c', 'i', 't', 'y'].to_vec()));
+
+ // Mixed case input: case preserved from stem
+ let mixed_cities: Vec<char> = "Cities".chars().collect();
+ let singulars = get_singulars(&FstDictionary::curated(), &mixed_cities);
+ assert!(singulars.contains(&['C', 'i', 't', 'y'].to_vec()));
+ }
+
+ #[test]
+ fn test_generated_candidates_must_validate() {
+ let plurals = get_plurals(&FstDictionary::curated(), &['a', 'n', 't']);
+ // "ants" should be in the dictionary as a plural noun
+ assert!(plurals.contains(&['a', 'n', 't', 's'].to_vec()));
+
+ // "buses" should be in the dictionary as a plural noun
+ let plurals = get_plurals(&FstDictionary::curated(), &['b', 'u', 's']);
+ assert!(plurals.contains(&['b', 'u', 's', 'e', 's'].to_vec()));
+ }
+}
diff --git a/harper-core/src/token_string_ext.rs b/harper-core/src/token_string_ext.rs
index 3b5e21f68..a5585a250 100644
--- a/harper-core/src/token_string_ext.rs
+++ b/harper-core/src/token_string_ext.rs
@@ -188,6 +188,15 @@ pub trait TokenStringExt: private::Sealed {
Some(&slice[start_idx..end_idx_plus_one])
}
+ // delegate to span
+ fn get_ch<'a>(&self, src: &'a [char]) -> Option<&'a [char]> {
+ self.span().map(|s| s.get_content(src))
+ }
+
+ fn get_str(&self, src: &[char]) -> Option<String> {
+ self.span().map(|s| s.get_content_string(src))
+ }
+
fn iter_linking_verb_indices(&self) -> impl Iterator<Item = usize> + '_ {
let tokens = self.tokens();
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 048f91ae6..3ced0d842 100644
--- a/harper-core/tests/text/linters/The Great Gatsby.snap.yml
+++ b/harper-core/tests/text/linters/The Great Gatsby.snap.yml
@@ -2632,6 +2632,17 @@ Suggest:
+Lint: Agreement (127 priority)
+Message: |
+ 1877 | “the boarder”—I doubt if he had any other home. Of theatrical people there were
+ | ^~~~~
+ 1878 | Gus Waize and Horace O’Donavan and Lester Myer and George Duckweed and Francis
+ | ~~~ There is disagreement in number between the verb and the noun.
+Suggest:
+ - Replace with: “was a Gus”
+
+
+
Lint: Spelling (63 priority)
Message: |
1877 | “the boarder”—I doubt if he had any other home. Of theatrical people there were
diff --git a/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md b/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md
index a76935ae0..e5f857ef0 100644
--- a/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md
+++ b/harper-core/tests/text/tagged/Alice's Adventures in Wonderland.md
@@ -1752,8 +1752,8 @@
#
> “ In my youth , ” Father William replied to his son , “ I feared it might injure
# . NPr/J/R/P D$+ NSg+ . . NPr/VB+ NPr+ VP/J P ISg/D$+ NPr/VB+ . . ISg/#r+ VP/J NPr/ISg+ Nᴹ/VXB/J VB
-> the brain ; But , now that I’m perfectly sure I have none , Why , I do it again
-# D+ NPr🅪Sg/VB+ . NSg/C/P . NSg/J/R/C I/C/Ddem+ K R J ISg/#r+ NSg/VXB NSg/I+ . NSg/VB . ISg/#r+ VXB NPr/ISg+ P
+> the brain ; But , now that I’m perfectly sure I have none , Why , I do it again
+# D+ NPr🅪Sg/VB+ . NSg/C/P . NSg/J/R/C I/C/Ddem+ K R J ISg/#r+ NSg/VXB I+ . NSg/VB . ISg/#r+ VXB NPr/ISg+ P
> and again . ”
# VB/C P . .
>
@@ -3370,8 +3370,8 @@
# . NSg/I+ R/C/P . . VP/J D+ NSg/I/J+ NPr/I+ VP VPp/J NSg/J .
>
#
-> “ That’s none of your business , Two ! ” said Seven .
-# . K NSg/I P D$+ N🅪Sg/J+ . NSg . . VP/J NSg .
+> “ That’s none of your business , Two ! ” said Seven .
+# . K I P D$+ N🅪Sg/J+ . NSg . . VP/J NSg .
>
#
> “ Yes , it is his business ! ” said Five , “ and I’ll tell him — it was for bringing the
@@ -5196,8 +5196,8 @@
# NSg P D NSg+ .
>
#
-> “ I keep them to sell , ” the Hatter added as an explanation ; “ I’ve none of my own .
-# . ISg/#r+ NSg/VB NSg/IPl+ P NSg/VB . . D NSg/VB VP/J R/C/P D/P N🅪Sg+ . . K NSg/I P D$+ NSg/VB/J .
+> “ I keep them to sell , ” the Hatter added as an explanation ; “ I’ve none of my own .
+# . ISg/#r+ NSg/VB NSg/IPl+ P NSg/VB . . D NSg/VB VP/J R/C/P D/P N🅪Sg+ . . K I P D$+ NSg/VB/J .
> I’m a hatter . ”
# K D/P NSg/VB . .
>
@@ -5790,8 +5790,8 @@
#
> The jury all wrote down on their slates , “ She doesn’t believe there’s an atom of
# D+ NSg/VB/J+ NSg/I/J/C/Dq VPt N🅪Sg/VB/J/P J/P D$+ NPl/V3 . . ISg+ VX3 VB K D/P NSg P
-> meaning in it , ” but none of them attempted to explain the paper .
-# N🅪Sg/Vg/J+ NPr/J/R/P NPr/ISg+ . . NSg/C/P NSg/I P NSg/IPl+ VP/J P VB D N🅪Sg/VB/J+ .
+> meaning in it , ” but none of them attempted to explain the paper .
+# N🅪Sg/Vg/J+ NPr/J/R/P NPr/ISg+ . . NSg/C/P I P NSg/IPl+ VP/J P VB D N🅪Sg/VB/J+ .
>
#
> “ If there’s no meaning in it , ” said the King , “ that saves a world of trouble ,
diff --git a/harper-core/tests/text/tagged/The Great Gatsby.md b/harper-core/tests/text/tagged/The Great Gatsby.md
index 4146506e6..e30180a46 100644
--- a/harper-core/tests/text/tagged/The Great Gatsby.md
+++ b/harper-core/tests/text/tagged/The Great Gatsby.md
@@ -5698,8 +5698,8 @@
# ISg/D$+ NPr/VB+ Nᴹ/Vg/J P D NSg/VB P NSg+ NPr/ISg+ NPr/VPt P ISg/D$+ NSg/VB/J/R . VP/J NPl/V3+ .
> Sometimes , too , he stared around at his possessions in a dazed way , as though in
# R . R . NPr/ISg+ VP/J J/P NSg/P ISg/D$+ NPl/V3+ NPr/J/R/P D/P+ VP/J+ NSg/J+ . R/C/P C NPr/J/R/P
-> her actual and astounding presence none of it was any longer real . Once he
-# ISg/D$+ NSg/J VB/C Nᴹ/Vg/J N🅪Sg/VB+ NSg/I P NPr/ISg+ VLPt I/R/Dq NSg/JC NSg/J . NSg/C NPr/ISg+
+> her actual and astounding presence none of it was any longer real . Once he
+# ISg/D$+ NSg/J VB/C Nᴹ/Vg/J N🅪Sg/VB+ I P NPr/ISg+ VLPt I/R/Dq NSg/JC NSg/J . NSg/C NPr/ISg+
> nearly toppled down a flight of stairs .
# R VP/J N🅪Sg/VB/J/P D/P N🅪Sg/VB/J P NPl+ .
>
@@ -6142,8 +6142,8 @@
# N🅪Sg/VB/J+ I/C/Ddem+ VP ISg+ NSg/I/J/Dq+ NPl/V3+ D/P NSg NSg/VP ISg+ R J NSg/C/P J/P
> the verge of soft - mindedness , and , suspecting this , an infinite number of women
# D NSg/VB P NSg/J . Nᴹ+ . VB/C . Nᴹ/Vg/J I/Ddem+ . D/P NSg/J N🅪Sg/VB/JC P NPl+
-> tried to separate him from his money . The none too savory ramifications by which
-# VP/J P NSg/VB/J ISg+ P ISg/D$+ N🅪Sg/J+ . D+ NSg/I+ R NSg/J + NSg/P I/C+
+> tried to separate him from his money . The none too savory ramifications by which
+# VP/J P NSg/VB/J ISg+ P ISg/D$+ N🅪Sg/J+ . D+ I+ R NSg/J + NSg/P I/C+
> Ella Kaye , the newspaper woman , played Madame de Maintenon to his weakness and
# NPr NPr . D N🅪Sg/VB+ NSg/VB+ . VP/J NSg+ NPr+ ? P ISg/D$+ N🅪Sg+ VB/C
> sent him to sea in a yacht , were common property of the turgid journalism