Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: flag "real estates" which doesn't pluralize (#1915)
Andrew Dunbar81d908d1ecc7
diff --git a/harper-core/src/linting/mass_plurals.rs b/harper-core/src/linting/mass_plurals.rsindex 062509ce1..b4507de47 100644--- a/harper-core/src/linting/mass_plurals.rs+++ b/harper-core/src/linting/mass_plurals.rs@@ -24,12 +24,17 @@ where});let oov_looks_plural = All::new(vec![Box::new(oov), Box::new(looks_plural)]);- let source_codes = FixedPhrase::from_phrase("source codes");+ // let source_codes = FixedPhrase::from_phrase("source codes");+ let phrases = FirstMatchOf::new(vec![+ Box::new(FixedPhrase::from_phrase("real estates")),+ Box::new(FixedPhrase::from_phrase("source codes")),+ ]);Self {expr: Box::new(FirstMatchOf::new(vec![Box::new(oov_looks_plural),- Box::new(source_codes),+ // Box::new(source_codes),+ Box::new(phrases),])),dict,}@@ -97,18 +102,8 @@ where}} else {// Multiple tokens means we matched a fixed phrase- let the_fixed_phrase = mistake_toks.span()?.get_content(src);- // For now the only one is "source codes" and the singular is "source code"- if the_fixed_phrase- .to_string()- .eq_ignore_ascii_case("source codes")- {- let source_code_chars: Box<[char]> = "source code"- .chars()- .collect::<Vec<char>>()- .into_boxed_slice();- legit_words_found.insert(source_code_chars);- }+ let phrase = mistake_toks.span()?.get_content(src);+ legit_words_found.insert(phrase[..phrase.len() - 1].into());}if legit_words_found.is_empty() {@@ -175,4 +170,14 @@ mod tests {1,);}++ // instead of giving any of her many luxury real estates or multi-million dollar fortune ...+ #[test]+ fn flag_real_estates() {+ assert_lint_count(+ "Instead of giving any of her many luxury real estates or multi-million dollar fortune ...",+ MassPlurals::new(FstDictionary::curated()),+ 1,+ );+ }}