Skip to content

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

Merge branch 'master' into harperjs-mutable-dictionary

Elijah Pottere9e76c2c215e
diff --cc harper-core/src/spell/fst_dictionary.rs
index edc12fa93,bd7f79cac..0e24eff61
--- a/harper-core/src/spell/fst_dictionary.rs
+++ b/harper-core/src/spell/fst_dictionary.rs
@@@ -213,9 -213,17 +213,21 @@@ impl Dictionary for FstDictionary
self.full_dict.words_with_len_iter(len)
}
+ fn word_count(&self) -> usize {
+ self.full_dict.word_count()
+ }
++
+ fn contains_exact_word(&self, word: &[char]) -> bool {
+ self.full_dict.contains_exact_word(word)
+ }
+
+ fn contains_exact_word_str(&self, word: &str) -> bool {
+ self.full_dict.contains_exact_word_str(word)
+ }
+
+ fn get_correct_capitalization_of(&self, word: &[char]) -> Option<&'_ [char]> {
+ self.full_dict.get_correct_capitalization_of(word)
+ }
}
#[cfg(test)]
diff --cc harper-core/src/spell/mutable_dictionary.rs
index d8696c95d,17f950701..8c3faef11
--- a/harper-core/src/spell/mutable_dictionary.rs
+++ b/harper-core/src/spell/mutable_dictionary.rs
@@@ -261,9 -284,14 +286,18 @@@ impl Dictionary for MutableDictionary
Box::new(self.words[start..end].iter().map(|v| v.as_slice()))
}
+ fn word_count(&self) -> usize {
+ self.words.len()
+ }
++
+ fn contains_exact_word(&self, word: &[char]) -> bool {
+ self.word_map.contains_key(seq_to_normalized(word).as_ref())
+ }
+
+ fn contains_exact_word_str(&self, word: &str) -> bool {
+ let word: CharString = word.chars().collect();
+ self.contains_exact_word(word.as_ref())
+ }
}
#[cfg(test)]