Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: defined conjunctions in metadata
Elijah Potterb389c163d2ff
diff --git a/harper-core/affixes.json b/harper-core/affixes.jsonindex fc87f8b94..7d7afdec9 100644--- a/harper-core/affixes.json+++ b/harper-core/affixes.json@@ -536,6 +536,15 @@"gifts_metadata": {"swear": true}+ },+ "7": {+ "suffix": true,+ "cross_product": true,+ "replacements": [],+ "adds_metadata": {},+ "gifts_metadata": {+ "conjunction": {}+ }}}}diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dictindex 8a63c515e..a90ae8643 100644--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@ -45444,7 +45444,7 @@ thalami/1thalamus/M1thalidomide/M1thallium/M1-than/+than/7thane/SM1thank/SDG14thankful/YP5diff --git a/harper-core/src/spell/full_dictionary.rs b/harper-core/src/spell/full_dictionary.rsindex 877654ba5..e59f7e30f 100644--- a/harper-core/src/spell/full_dictionary.rs+++ b/harper-core/src/spell/full_dictionary.rs@@ -191,4 +191,11 @@ mod tests {assert!(dict.get_word_metadata_str("this").is_noun());assert!(dict.get_word_metadata_str("This").is_noun());}++ #[test]+ fn than_is_conjunction() {+ 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.rsindex 68e38a711..4f109aa90 100644--- a/harper-core/src/word_metadata.rs+++ b/harper-core/src/word_metadata.rs@@ -7,6 +7,7 @@ pub struct WordMetadata {pub verb: Option<VerbData>,pub adjective: Option<AdjectiveData>,pub adverb: Option<AdverbData>,+ pub conjunction: Option<ConjunctionData>,pub swear: Option<bool>}@@ -18,6 +19,7 @@ impl WordMetadata {verb: self.verb.or(other.verb),adjective: self.adjective.or(other.adjective),adverb: self.adverb.or(other.adverb),+ conjunction: self.conjunction.or(other.conjunction),swear: self.swear.or(other.swear)}}@@ -26,6 +28,10 @@ impl WordMetadata {self.noun.is_some()}+ pub fn is_conjunction(&self) -> bool {+ self.conjunction.is_some()+ }+pub fn is_verb(&self) -> bool {self.verb.is_some()}@@ -150,3 +156,13 @@ impl AdverbData {Self {}}}++#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Hash)]+pub struct ConjunctionData {}++impl ConjunctionData {+ /// Produce a copy of `self` with the known properties of `other` set.+ pub fn or(&self, _other: &Self) -> Self {+ Self {}+ }+}