Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
feat: created pattern linter and pattern system
Elijah Potter6107594eedf1
diff --git a/Cargo.lock b/Cargo.lockindex a43966c53..b2f6b69a2 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -607,6 +607,7 @@ dependencies = ["hashbrown","is-macro","itertools 0.13.0",+ "ordered-float","paste","pulldown-cmark","rand",@@ -952,6 +953,17 @@ version = "0.2.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"+[[package]]+name = "ordered-float"+version = "4.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4a91171844676f8c7990ce64959210cd2eaef32c2612c50f9fae9f8aaa6065a6"+dependencies = [+ "num-traits",+ "rand",+ "serde",+]+[[package]]name = "overload"version = "0.1.1"@@ -1101,6 +1113,7 @@ dependencies = ["libc","rand_chacha","rand_core",+ "serde",][[package]]@@ -1120,6 +1133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"dependencies = ["getrandom",+ "serde",][[package]]diff --git a/harper-core/Cargo.toml b/harper-core/Cargo.tomlindex ac99a7155..c90e39132 100644--- a/harper-core/Cargo.toml+++ b/harper-core/Cargo.toml@@ -12,6 +12,7 @@ blanket = "0.4.0"hashbrown = { version = "0.14.3", features = ["serde"] }is-macro = "0.3.6"itertools = "0.13.0"+ordered-float = { version = "4.2.2", features = ["serde"] }paste = "1.0.14"pulldown-cmark = "0.11.0"serde = { version = "1.0.209", features = ["derive"] }diff --git a/harper-core/src/document.rs b/harper-core/src/document.rsindex 8fa6fac8f..21739f390 100644--- a/harper-core/src/document.rs+++ b/harper-core/src/document.rs@@ -6,6 +6,7 @@ use itertools::Itertools;use paste::paste;use crate::parsers::{Markdown, Parser, PlainEnglish};+use crate::patterns::Pattern;use crate::punctuation::Punctuation;use crate::span::Span;use crate::token::NumberSuffix;@@ -311,6 +312,14 @@ impl Document {&self.source}+ pub fn get_source(&self) -> &[char] {+ &self.source+ }++ pub fn get_tokens(&self) -> &[Token] {+ &self.tokens+ }+/// Searches for quotation marks and fills the/// [`Punctuation::Quote::twin_loc`] field. This is on a best effort/// basis.diff --git a/harper-core/src/lexing/mod.rs b/harper-core/src/lexing/mod.rsindex a6b6d8ed2..529c95522 100644--- a/harper-core/src/lexing/mod.rs+++ b/harper-core/src/lexing/mod.rs@@ -76,7 +76,7 @@ pub fn lex_number(source: &[char]) -> Option<FoundToken> {if let Ok(n) = s.parse::<f64>() {return Some(FoundToken {- token: TokenKind::Number(n, None),+ token: TokenKind::Number(n.into(), None),next_index: end + 1});}diff --git a/harper-core/src/lib.rs b/harper-core/src/lib.rsindex 498f73ce7..9e38d713b 100644--- a/harper-core/src/lib.rs+++ b/harper-core/src/lib.rs@@ -9,6 +9,7 @@ mod lexing;pub mod linting;mod mask;pub mod parsers;+pub mod patterns;mod punctuation;mod span;mod spell;diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rsindex cc7bdcdb1..abe9a8705 100644--- a/harper-core/src/linting/lint_group.rs+++ b/harper-core/src/linting/lint_group.rs@@ -15,7 +15,7 @@ use super::spell_check::SpellCheck;use super::spelled_numbers::SpelledNumbers;use super::unclosed_quotes::UnclosedQuotes;use super::wrong_quotes::WrongQuotes;-use super::{Lint, Linter};+use super::{Lint, Linter, PatternLinter};use crate::{Dictionary, Document};macro_rules! create_lint_group_config {diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rsindex dcaad71ef..65f09639b 100644--- a/harper-core/src/linting/mod.rs+++ b/harper-core/src/linting/mod.rs@@ -7,6 +7,7 @@ mod long_sentences;mod matcher;mod multiple_sequential_pronouns;mod number_suffix_capitalization;+mod pattern_linter;mod repeated_words;mod sentence_capitalization;mod spaces;@@ -24,6 +25,7 @@ pub use long_sentences::LongSentences;pub use matcher::Matcher;pub use multiple_sequential_pronouns::MultipleSequentialPronouns;pub use number_suffix_capitalization::NumberSuffixCapitalization;+pub use pattern_linter::PatternLinter;pub use repeated_words::RepeatedWords;pub use sentence_capitalization::SentenceCapitalization;pub use spaces::Spaces;diff --git a/harper-core/src/linting/multiple_sequential_pronouns.rs b/harper-core/src/linting/multiple_sequential_pronouns.rsindex 7ab2a3ec0..4efa14c22 100644--- a/harper-core/src/linting/multiple_sequential_pronouns.rs+++ b/harper-core/src/linting/multiple_sequential_pronouns.rs@@ -1,78 +1,51 @@+use hashbrown::HashSet;++use super::pattern_linter::PatternLinter;use crate::linting::{LintKind, Linter};-use crate::{CharString, Document, Lint, Span, Token, TokenStringExt};+use crate::patterns::{Pattern, TokenSequencePattern};+use crate::{CharString, Document, Lint, Lrc, Span, Token, TokenStringExt};/// Linter that checks if multiple pronouns are being used right after each/// other. This is a common mistake to make during the revision process.-#[derive(Debug)]pub struct MultipleSequentialPronouns {- /// Since there aren't many pronouns, it's faster to store this as a vector.- pronouns: Vec<CharString>+ pattern: Box<dyn Pattern + Send + Sync>}impl MultipleSequentialPronouns {fn new() -> Self {- let pronoun_strs = [+ let pronouns: HashSet<_> = ["me", "my", "I", "we", "you", "he", "him", "her", "she", "it", "they"- ];-- let mut pronouns: Vec<CharString> = pronoun_strs- .iter()- .map(|s| s.chars().collect::<CharString>())- .collect();+ ]+ .into_iter()+ .collect();- pronouns.sort();+ let pronouns = Lrc::new(pronouns);- Self { pronouns }- }+ let mut pattern = TokenSequencePattern::default();+ pattern+ .then_any_word_in(pronouns.clone())+ .then_whitespace()+ .then_any_word_in(pronouns.clone());- fn is_pronoun(&self, word: &[char]) -> bool {- self.pronouns- .binary_search_by_key(&word, |w| w.as_slice())- .is_ok()+ Self {+ pattern: Box::new(pattern)+ }}}-impl Linter for MultipleSequentialPronouns {- fn lint(&mut self, document: &Document) -> Vec<Lint> {- let mut lints = Vec::new();-- let mut found_pronouns = Vec::new();-- let mut emit_lint = |found_pronouns: &mut Vec<Token>| {- let first: &Token = found_pronouns.first().unwrap();- let last: &Token = found_pronouns.last().unwrap();-- lints.push(Lint {- span: Span::new(first.span.start, last.span.end),- lint_kind: LintKind::Repetition,- message: "There are too many personal pronouns in sequence here.".to_owned(),- priority: 63,- ..Default::default()- });- found_pronouns.clear();- };-- for chunk in document.chunks() {- for word in chunk.iter_words() {- let word_chars = document.get_span_content(word.span);-- if self.is_pronoun(word_chars) {- found_pronouns.push(word);- } else if found_pronouns.len() == 1 {- found_pronouns.clear();- } else if found_pronouns.len() > 1 {- emit_lint(&mut found_pronouns);- }- }-- if found_pronouns.len() > 1 {- emit_lint(&mut found_pronouns);- }+impl PatternLinter for MultipleSequentialPronouns {+ fn pattern(&self) -> &dyn crate::patterns::Pattern {+ self.pattern.as_ref()+ }- found_pronouns.clear();+ fn match_to_lint(&self, matched_tokens: &[Token], _source: &[char]) -> Lint {+ Lint {+ span: matched_tokens.span().unwrap(),+ lint_kind: LintKind::Repetition,+ message: "There are too many personal pronouns in sequence here.".to_owned(),+ priority: 63,+ ..Default::default()}-- lints}}diff --git a/harper-core/src/linting/pattern_linter.rs b/harper-core/src/linting/pattern_linter.rsnew file mode 100644index 000000000..9572e9cbe--- /dev/null+++ b/harper-core/src/linting/pattern_linter.rs@@ -0,0 +1,33 @@+use super::{Lint, Linter};+use crate::patterns::Pattern;+use crate::Token;++pub trait PatternLinter {+ /// A simple getter for the pattern to be searched for.+ fn pattern(&self) -> &dyn Pattern;+ fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Lint;+}++impl<L> Linter for L+where+ L: PatternLinter + Send + Sync+{+ fn lint(&mut self, document: &crate::Document) -> Vec<Lint> {+ let mut lints = Vec::new();+ let source = document.get_source();++ for chunk in document.chunks() {+ for i in 0..chunk.len() {+ let match_len = self.pattern().matches(&chunk[i..], source);++ if match_len != 0 {+ let lint = self.match_to_lint(&chunk[i..i + match_len], source);++ lints.push(lint);+ }+ }+ }++ lints+ }+}diff --git a/harper-core/src/linting/spelled_numbers.rs b/harper-core/src/linting/spelled_numbers.rsindex 0a6713f01..3cad5c596 100644--- a/harper-core/src/linting/spelled_numbers.rs+++ b/harper-core/src/linting/spelled_numbers.rs@@ -12,6 +12,7 @@ impl Linter for SpelledNumbers {for number_tok in document.iter_numbers() {let (number, _suffix) = number_tok.kind.number().unwrap();+ let number: f64 = number.into();if (number - number.floor()).abs() < f64::EPSILON && number <= 100. {lints.push(Lint {diff --git a/harper-core/src/patterns/mod.rs b/harper-core/src/patterns/mod.rsnew file mode 100644index 000000000..94fcc2381--- /dev/null+++ b/harper-core/src/patterns/mod.rs@@ -0,0 +1,17 @@+use crate::Token;++mod naive_pattern_group;+mod token_kind_pattern_group;+mod token_pattern;+mod token_sequence_pattern;+mod word_pattern_group;++pub use naive_pattern_group::NaivePatternGroup;+pub use token_kind_pattern_group::TokenKindPatternGroup;+pub use token_pattern::TokenPattern;+pub use token_sequence_pattern::TokenSequencePattern;+pub use word_pattern_group::WordPatternGroup;++pub trait Pattern {+ fn matches(&self, tokens: &[Token], source: &[char]) -> usize;+}diff --git a/harper-core/src/patterns/naive_pattern_group.rs b/harper-core/src/patterns/naive_pattern_group.rsnew file mode 100644index 000000000..a1be5b88c--- /dev/null+++ b/harper-core/src/patterns/naive_pattern_group.rs@@ -0,0 +1,38 @@+use super::Pattern;++/// A naive pattern collection that naively iterates through a list of patterns,+/// returning the first one that matches..+pub struct NaivePatternGroup {+ patterns: Vec<Box<dyn Pattern>>+}++impl NaivePatternGroup {+ pub fn push(&mut self, pattern: Box<dyn Pattern>) {+ self.patterns.push(pattern);+ }+}++impl Pattern for NaivePatternGroup {+ fn matches(&self, tokens: &[crate::Token], source: &[char]) -> usize {+ self.patterns+ .iter()+ .find_map(|p| {+ let res = p.matches(tokens, source);++ if res != 0 {+ Some(res)+ } else {+ None+ }+ })+ .unwrap_or_default()+ }+}++impl Default for NaivePatternGroup {+ fn default() -> Self {+ Self {+ patterns: Default::default()+ }+ }+}diff --git a/harper-core/src/patterns/token_kind_pattern_group.rs b/harper-core/src/patterns/token_kind_pattern_group.rsnew file mode 100644index 000000000..d8904f1f6--- /dev/null+++ b/harper-core/src/patterns/token_kind_pattern_group.rs@@ -0,0 +1,23 @@+use hashbrown::HashMap;++use super::Pattern;+use crate::{Token, TokenKind};++pub struct TokenKindPatternGroup {+ /// These are patterns whose first token's kind must be strictly equal.+ strict_patterns: HashMap<TokenKind, Box<dyn Pattern>>+}++impl Pattern for TokenKindPatternGroup {+ fn matches(&self, tokens: &[Token], source: &[char]) -> usize {+ let Some(first_kind) = &tokens.first().map(|t| t.kind) else {+ return 0;+ };++ let Some(pattern) = self.strict_patterns.get(first_kind) else {+ return 0;+ };++ pattern.matches(tokens, source)+ }+}diff --git a/harper-core/src/patterns/token_pattern.rs b/harper-core/src/patterns/token_pattern.rsnew file mode 100644index 000000000..0cfcc15fe--- /dev/null+++ b/harper-core/src/patterns/token_pattern.rs@@ -0,0 +1,78 @@+use hashbrown::HashSet;+use is_macro::Is;++use super::Pattern;+use crate::{Lrc, Token, TokenKind};++/// A pattern that matches a single token.+#[derive(Debug, Clone, Is)]+pub enum TokenPattern {+ /// Checks that the overall kind of token matches, not whether the inner+ /// data does.+ KindLoose(TokenKind),+ /// Checks that the kind matches exactly.+ KindStrict(TokenKind),+ WhiteSpace,+ WordExact(&'static str),+ WordInSet(Lrc<HashSet<&'static str>>)+}++impl Pattern for TokenPattern {+ fn matches(&self, tokens: &[Token], source: &[char]) -> usize {+ let Some(tok) = tokens.first() else {+ return 0;+ };++ match self {+ TokenPattern::KindLoose(kind) => {+ if kind.with_default_data() == tok.kind.with_default_data() {+ 1+ } else {+ 0+ }+ }+ TokenPattern::KindStrict(kind) => {+ if *kind == tok.kind {+ 1+ } else {+ 0+ }+ }+ TokenPattern::WhiteSpace => tokens+ .iter()+ .position(|t| !t.kind.is_whitespace())+ .unwrap_or(tokens.len()),+ TokenPattern::WordExact(word) => {+ if !tok.kind.is_word() {+ return 0;+ }++ let tok_chars = tok.span.get_content(source);++ let mut w_char_count = 0;+ for (i, w_char) in word.chars().enumerate() {+ w_char_count += 1;++ if tok_chars.get(i).cloned() != Some(w_char) {+ return 0;+ }+ }++ if w_char_count == tok_chars.len() {+ 1+ } else {+ 0+ }+ }+ TokenPattern::WordInSet(set) => {+ let tok_chars = tok.span.get_content(source);+ let word: String = tok_chars.iter().collect();+ if set.contains(word.as_str()) {+ 1+ } else {+ 0+ }+ }+ }+ }+}diff --git a/harper-core/src/patterns/token_sequence_pattern.rs b/harper-core/src/patterns/token_sequence_pattern.rsnew file mode 100644index 000000000..275b588bf--- /dev/null+++ b/harper-core/src/patterns/token_sequence_pattern.rs@@ -0,0 +1,119 @@+use hashbrown::HashSet;++use super::token_pattern::TokenPattern;+use super::Pattern;+use crate::{Lrc, Token, TokenKind};++/// A pattern that checks that a sequence of [`TokenPattern`] matches.+#[derive(Debug, Default)]+pub struct TokenSequencePattern {+ token_patterns: Vec<TokenPattern>+}++impl TokenSequencePattern {+ pub fn then_exact_word(&mut self, word: &'static str) -> &mut Self {+ self.token_patterns.push(TokenPattern::WordExact(word));+ self+ }++ pub fn then_loose(&mut self, kind: TokenKind) -> &mut Self {+ self.token_patterns.push(TokenPattern::KindLoose(kind));+ self+ }++ pub fn then_any_word(&mut self) -> &mut Self {+ self.token_patterns+ .push(TokenPattern::KindLoose(TokenKind::blank_word()));+ self+ }++ pub fn then_strict(&mut self, kind: TokenKind) -> &mut Self {+ self.token_patterns.push(TokenPattern::KindStrict(kind));+ self+ }++ pub fn then_whitespace(&mut self) -> &mut Self {+ self.token_patterns.push(TokenPattern::WhiteSpace);+ self+ }++ pub fn then_any_word_in(&mut self, word_set: Lrc<HashSet<&'static str>>) -> &mut Self {+ self.token_patterns+ .push(TokenPattern::WordInSet(word_set.into()));+ self+ }+}++impl Pattern for TokenSequencePattern {+ fn matches(&self, tokens: &[Token], source: &[char]) -> usize {+ let mut tok_cursor = 0;++ for pat in self.token_patterns.iter() {+ let match_length = pat.matches(&tokens[tok_cursor..], source);++ if match_length == 0 {+ return 0;+ }++ tok_cursor += match_length;+ }++ tok_cursor+ }+}++#[cfg(test)]+mod tests {+ use hashbrown::HashSet;++ use super::TokenSequencePattern;+ use crate::patterns::Pattern;+ use crate::{Document, Lrc};++ #[test]+ fn matches_n_whitespace_tokens() {+ let mut pat = TokenSequencePattern::default();+ pat.then_any_word().then_whitespace().then_any_word();+ let doc = Document::new_plain_english_curated("word\n \nword");++ assert_eq!(+ pat.matches(doc.get_tokens(), doc.get_source()),+ doc.get_tokens().len()+ );+ }++ #[test]+ fn matches_specific_words() {+ let mut pat = TokenSequencePattern::default();+ pat.then_exact_word("she")+ .then_whitespace()+ .then_exact_word("her");+ let doc = Document::new_plain_english_curated("she her");++ assert_eq!(+ pat.matches(doc.get_tokens(), doc.get_source()),+ doc.get_tokens().len()+ );+ }++ #[test]+ fn matches_sets() {+ let mut pronouns = HashSet::new();+ pronouns.insert("his");+ pronouns.insert("hers");+ let pronouns = Lrc::new(pronouns);++ let mut pat = TokenSequencePattern::default();+ pat.then_exact_word("it")+ .then_whitespace()+ .then_exact_word("was")+ .then_whitespace()+ .then_any_word_in(pronouns);+ let doc = Document::new_plain_english_curated("it was hers");++ assert_eq!(+ pat.matches(doc.get_tokens(), doc.get_source()),+ doc.get_tokens().len()+ );+ }+}diff --git a/harper-core/src/patterns/word_pattern_group.rs b/harper-core/src/patterns/word_pattern_group.rsnew file mode 100644index 000000000..fd4e00e5a--- /dev/null+++ b/harper-core/src/patterns/word_pattern_group.rs@@ -0,0 +1,48 @@+use hashbrown::HashMap;++use super::naive_pattern_group::NaivePatternGroup;+use super::Pattern;+use crate::CharString;++/// A pattern collection to look for patterns that start with a specific+/// word.+pub struct WordPatternGroup<P>+where+ P: Pattern+{+ patterns: HashMap<CharString, P>+}++impl WordPatternGroup<NaivePatternGroup> {+ pub fn add(&mut self, word: &[char], pat: Box<dyn Pattern>) {+ if let Some(group) = self.patterns.get_mut(word) {+ group.push(pat);+ } else {+ let mut group = NaivePatternGroup::default();+ group.push(pat);+ self.patterns.insert(word.into(), group);+ }+ }+}++impl<P> Pattern for WordPatternGroup<P>+where+ P: Pattern+{+ fn matches(&self, tokens: &[crate::Token], source: &[char]) -> usize {+ let Some(first) = tokens.first() else {+ return 0;+ };++ if !first.kind.is_word() {+ return 0;+ }++ let word_chars = first.span.get_content(source);+ let Some(inner_pattern) = self.patterns.get(word_chars) else {+ return 0;+ };++ inner_pattern.matches(tokens, source)+ }+}diff --git a/harper-core/src/punctuation.rs b/harper-core/src/punctuation.rsindex 6d8fb731f..f5b1b8646 100644--- a/harper-core/src/punctuation.rs+++ b/harper-core/src/punctuation.rs@@ -1,7 +1,9 @@use is_macro::Is;use serde::{Deserialize, Serialize};-#[derive(Debug, Is, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Default)]+#[derive(+ Debug, Is, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Default, Hash,+)]#[serde(tag = "kind")]pub enum Punctuation {/// `…`@@ -119,7 +121,7 @@ impl Punctuation {}}-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, PartialOrd)]+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Hash)]pub struct Quote {/// The location of the matching quote, if it exists.pub twin_loc: Option<usize>diff --git a/harper-core/src/token.rs b/harper-core/src/token.rsindex d521ca1a6..c12e00566 100644--- a/harper-core/src/token.rs+++ b/harper-core/src/token.rs@@ -1,5 +1,6 @@use is_macro::Is;use itertools::Itertools;+use ordered_float::OrderedFloat;use paste::paste;use serde::{Deserialize, Serialize};@@ -37,12 +38,14 @@ pub struct FatToken {pub kind: TokenKind}-#[derive(Debug, Is, Clone, Copy, Serialize, Deserialize, PartialEq, Default, PartialOrd)]+#[derive(+ Debug, Is, Clone, Copy, Serialize, Deserialize, Default, PartialOrd, Hash, Eq, PartialEq,+)]#[serde(tag = "kind", content = "value")]pub enum TokenKind {Word(WordMetadata),Punctuation(Punctuation),- Number(f64, Option<NumberSuffix>),+ Number(OrderedFloat<f64>, Option<NumberSuffix>),/// A sequence of " " spaces.Space(usize),/// A sequence of "\n" newlines@@ -98,7 +101,9 @@ impl TokenKind {}}-#[derive(Debug, Serialize, Deserialize, Default, PartialEq, PartialOrd, Clone, Copy, Is)]+#[derive(+ Debug, Serialize, Deserialize, Default, PartialEq, PartialOrd, Clone, Copy, Is, Hash, Eq,+)]pub enum NumberSuffix {#[default]Th,@@ -108,7 +113,9 @@ pub enum NumberSuffix {}impl NumberSuffix {- pub fn correct_suffix_for(number: f64) -> Option<Self> {+ pub fn correct_suffix_for(number: impl Into<f64>) -> Option<Self> {+ let number = number.into();+if number < 0.0 || number - number.floor() > f64::EPSILON || number > u64::MAX as f64 {return None;}diff --git a/harper-core/src/word_metadata.rs b/harper-core/src/word_metadata.rsindex d244eb5b6..8891dc8bd 100644--- a/harper-core/src/word_metadata.rs+++ b/harper-core/src/word_metadata.rs@@ -1,7 +1,7 @@use is_macro::Is;use serde::{Deserialize, Serialize};-#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, PartialOrd)]+#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Hash)]pub struct WordMetadata {noun: Option<NounData>,verb: Option<VerbData>,@@ -83,14 +83,14 @@ impl WordMetadata {}}-#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Is)]+#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Is, Hash)]pub enum Tense {Past,Present,Future}-#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq)]+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Hash)]pub struct VerbData {pub is_linking: Option<bool>,pub tense: Option<Tense>@@ -106,7 +106,7 @@ impl VerbData {}}-#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq)]+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Hash)]pub struct NounData {pub is_proper: Option<bool>,pub is_plural: Option<bool>,@@ -124,7 +124,7 @@ impl NounData {}}-#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq)]+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Hash)]pub struct AdjectiveData {}impl AdjectiveData {@@ -134,7 +134,7 @@ impl AdjectiveData {}}-#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq)]+#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, PartialOrd, Eq, Hash)]pub struct AdverbData {}impl AdverbData {