Skip to content

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

fix(core): recognize "esp." as an abbreviation (#2816)

Naveen Prasanth95bb75faa695
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index 395f9a3c9..896785b92 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -23704,6 +23704,7 @@ esophagi/N9
esophagus/~N0g
esoteric/~JNQ
esp/~
+esp./~ # abbreviation for "especially"
espadrille/NgS
espalier/NgSVdG
especial/JY
diff --git a/harper-core/src/document.rs b/harper-core/src/document.rs
index e035f1c09..33a7a2a52 100644
--- a/harper-core/src/document.rs
+++ b/harper-core/src/document.rs
@@ -145,7 +145,7 @@ impl Document {
self.condense_dotted_initialisms();
self.condense_number_suffixes();
self.condense_ellipsis();
- self.condense_latin();
+ self.condense_dotted_truncations();
self.condense_common_top_level_domains();
self.condense_filename_extensions();
self.condense_tldr();
@@ -501,12 +501,12 @@ impl Document {
}
thread_local! {
- static LATIN_EXPR: Lrc<FirstMatchOf> = Document::uncached_latin_expr();
+ static DOTTED_TRUNCATION_EXPR: Lrc<FirstMatchOf> = Document::uncached_dotted_truncation_expr();
}
- fn uncached_latin_expr() -> Lrc<FirstMatchOf> {
+ fn uncached_dotted_truncation_expr() -> Lrc<FirstMatchOf> {
Lrc::new(FirstMatchOf::new(vec![
- Box::new(SequenceExpr::word_set(&["etc", "vs"]).then_period()),
+ Box::new(SequenceExpr::word_set(&["esp", "etc", "vs"]).then_period()),
Box::new(
SequenceExpr::aco("et")
.then_whitespace()
@@ -535,8 +535,8 @@ impl Document {
self.tokens.remove_indices(remove_indices);
}
- fn condense_latin(&mut self) {
- self.condense_expr(&Self::LATIN_EXPR.with(|v| v.clone()), |_| {})
+ fn condense_dotted_truncations(&mut self) {
+ self.condense_expr(&Self::DOTTED_TRUNCATION_EXPR.with(|v| v.clone()), |_| {})
}
/// Searches for multiple sequential newline tokens and condenses them down
diff --git a/harper-core/src/linting/sentence_capitalization.rs b/harper-core/src/linting/sentence_capitalization.rs
index 13805a297..838181126 100644
--- a/harper-core/src/linting/sentence_capitalization.rs
+++ b/harper-core/src/linting/sentence_capitalization.rs
@@ -239,6 +239,15 @@ mod tests {
)
}
+ #[test]
+ fn doesnt_flag_after_esp_issue_2753() {
+ assert_lint_count(
+ "I'll go, esp. if it's a free event.",
+ SentenceCapitalization::new(FstDictionary::curated()),
+ 0,
+ );
+ }
+
#[test]
fn allow_lower_camel_case_non_proper_nouns() {
// A very few words are not considered proper nouns but still start with a lowercase letter that shouldn't be uppercased at the start of a sentence.