From 8754aa14fe5f6387d4f55df98b5a5262145ca2df Mon Sep 17 00:00:00 2001 From: Elijah Potter Date: Tue, 3 Sep 2024 23:12:48 -0600 Subject: [PATCH] feat: defined pronouns in word metadata --- harper-core/affixes.json | 11 +++++++++++ harper-core/dictionary.dict | 2 +- harper-core/src/spell/full_dictionary.rs | 7 +++++++ harper-core/src/word_metadata.rs | 16 ++++++++++++++-- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/harper-core/affixes.json b/harper-core/affixes.json index 7d7afdec..b8ddd8a1 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 a90ae864..83057195 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 e59f7e30..e63c5c5c 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 4f109aa9..c71914ff 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, pub is_plural: Option, - pub is_possessive: Option + pub is_possessive: Option, + pub is_pronoun: Option } 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) } } }