Skip to content

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

feat: defined pronouns in word metadata

Elijah Potter8754aa14fe5f
diff --git a/harper-core/affixes.json b/harper-core/affixes.json
index 7d7afdec9..b8ddd8a1d 100644
--- a/harper-core/affixes.json
+++ b/harper-core/affixes.json
@@ -545,6 +545,17 @@
"gifts_metadata": {
"conjunction": {}
}
+ },
+ "8": {
+ "suffix": true,
+ "cross_product": true,
+ "replacements": [],
+ "adds_metadata": {},
+ "gifts_metadata": {
+ "noun": {
+ "is_pronoun": true
+ }
+ }
}
}
}
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index a90ae8643..830571953 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -26703,7 +26703,7 @@ herpetologist/SM1
herpetology/M1
herring/MS1
herringbone/M14
-herself/
+herself/8
hertz/M1
hesitance/M1
hesitancy/M1
diff --git a/harper-core/src/spell/full_dictionary.rs b/harper-core/src/spell/full_dictionary.rs
index e59f7e30f..e63c5c5c7 100644
--- a/harper-core/src/spell/full_dictionary.rs
+++ b/harper-core/src/spell/full_dictionary.rs
@@ -198,4 +198,11 @@ mod tests {
assert!(dict.get_word_metadata_str("than").is_conjunction());
assert!(dict.get_word_metadata_str("Than").is_conjunction());
}
+
+ #[test]
+ fn herself_is_pronoun() {
+ let dict = FullDictionary::curated();
+ assert!(dict.get_word_metadata_str("than").is_conjunction());
+ assert!(dict.get_word_metadata_str("Than").is_conjunction());
+ }
}
diff --git a/harper-core/src/word_metadata.rs b/harper-core/src/word_metadata.rs
index 4f109aa90..c71914ffc 100644
--- a/harper-core/src/word_metadata.rs
+++ b/harper-core/src/word_metadata.rs
@@ -74,6 +74,16 @@ impl WordMetadata {
)
}
+ pub fn is_pronoun(&self) -> bool {
+ matches!(
+ self.noun,
+ Some(NounData {
+ is_pronoun: Some(true),
+ ..
+ })
+ )
+ }
+
pub fn is_linking_verb(&self) -> bool {
matches!(
self.verb,
@@ -123,7 +133,8 @@ impl VerbData {
pub struct NounData {
pub is_proper: Option<bool>,
pub is_plural: Option<bool>,
- pub is_possessive: Option<bool>
+ pub is_possessive: Option<bool>,
+ pub is_pronoun: Option<bool>
}
impl NounData {
@@ -132,7 +143,8 @@ impl NounData {
Self {
is_proper: self.is_proper.or(other.is_proper),
is_plural: self.is_plural.or(other.is_plural),
- is_possessive: self.is_possessive.or(other.is_possessive)
+ is_possessive: self.is_possessive.or(other.is_possessive),
+ is_pronoun: self.is_pronoun.or(other.is_pronoun)
}
}
}