Skip to content

Commit

Permalink
feat: defined pronouns in word metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-potter committed Sep 4, 2024
1 parent 0db90af commit 8754aa1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
11 changes: 11 additions & 0 deletions harper-core/affixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,17 @@
"gifts_metadata": {
"conjunction": {}
}
},
"8": {
"suffix": true,
"cross_product": true,
"replacements": [],
"adds_metadata": {},
"gifts_metadata": {
"noun": {
"is_pronoun": true
}
}
}
}
}
2 changes: 1 addition & 1 deletion harper-core/dictionary.dict
Original file line number Diff line number Diff line change
Expand Up @@ -26703,7 +26703,7 @@ herpetologist/SM1
herpetology/M1
herring/MS1
herringbone/M14
herself/
herself/8
hertz/M1
hesitance/M1
hesitancy/M1
Expand Down
7 changes: 7 additions & 0 deletions harper-core/src/spell/full_dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
16 changes: 14 additions & 2 deletions harper-core/src/word_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit 8754aa1

Please sign in to comment.