Skip to content

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

feat: proper noun capitalization for Malaysia

hippietraila1128c6b1c02
diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rs
index 8c000c979..a38a13cbd 100644
--- a/harper-core/src/linting/lint_group.rs
+++ b/harper-core/src/linting/lint_group.rs
@@ -38,7 +38,7 @@ use super::possessive_your::PossessiveYour;
use super::pronoun_contraction::PronounContraction;
use super::proper_noun_capitalization_linters::{
AmazonNames, Americas, AppleNames, AzureNames, ChineseCommunistParty, GoogleNames, Holidays,
- Koreas, MetaNames, MicrosoftNames, UnitedOrganizations,
+ Koreas, Malaysia, MetaNames, MicrosoftNames, UnitedOrganizations,
};
use super::repeated_words::RepeatedWords;
use super::sentence_capitalization::SentenceCapitalization;
@@ -245,6 +245,7 @@ create_lint_group_config!(
CapitalizePersonalPronouns => true,
Americas => true,
Koreas => true,
+ Malaysia => true,
ChineseCommunistParty => true,
UnitedOrganizations => true,
Holidays => true,
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index 52b799fc6..737ccdf72 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -94,7 +94,7 @@ pub use possessive_your::PossessiveYour;
pub use pronoun_contraction::PronounContraction;
pub use proper_noun_capitalization_linters::{
AmazonNames, Americas, AppleNames, AzureNames, ChineseCommunistParty, GoogleNames, Holidays,
- Koreas, MetaNames, MicrosoftNames, UnitedOrganizations,
+ Koreas, Malaysia, MetaNames, MicrosoftNames, UnitedOrganizations,
};
pub use repeated_words::RepeatedWords;
pub use sentence_capitalization::SentenceCapitalization;
diff --git a/harper-core/src/linting/proper_noun_capitalization_linters.rs b/harper-core/src/linting/proper_noun_capitalization_linters.rs
index feadeb0e3..244ba544a 100644
--- a/harper-core/src/linting/proper_noun_capitalization_linters.rs
+++ b/harper-core/src/linting/proper_noun_capitalization_linters.rs
@@ -77,6 +77,60 @@ create_linter_for!(
"When referring to the nations, make sure to treat them as a proper noun."
);
+create_linter_for!(
+ Malaysia,
+ EitherPattern::new(vec![
+ // multi-word states
+ Box::new(SequencePattern::default()
+ .t_aco("Negeri")
+ .then_whitespace()
+ .t_aco("Sembilan")
+ ),
+ // multi-word state capitals
+ Box::new(SequencePattern::default()
+ .t_aco("Alor")
+ .then_whitespace()
+ .t_aco("Setar")
+ ),
+ Box::new(SequencePattern::default()
+ .t_aco("George")
+ .then_whitespace()
+ .t_aco("Town")
+ ),
+ Box::new(SequencePattern::default()
+ .then(Box::new(EitherPattern::new(vec![
+ Box::new(WordSet::all(&[
+ "Johor",
+ "Kota"
+ ])),
+ ])))
+ .then_whitespace()
+ .t_aco("Bahru")
+ ),
+ Box::new(SequencePattern::default()
+ .t_aco("Kota")
+ .then_whitespace()
+ .t_aco("Kinabalu")
+ ),
+ Box::new(SequencePattern::default()
+ .t_aco("Kuala")
+ .then_whitespace()
+ .then(Box::new(EitherPattern::new(vec![
+ Box::new(WordSet::all(&[
+ "Lumpur",
+ "Terengganu"
+ ])),
+ ])))
+ ),
+ Box::new(SequencePattern::default()
+ .t_aco("Shah")
+ .then_whitespace()
+ .t_aco("Alam")
+ )
+ ]),
+ "When referring to the states of Malaysia and their capitals, make sure to treat them as a proper noun."
+);
+
create_linter_for!(
ChineseCommunistParty,
SequencePattern::aco("Chinese")