Skip to content

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

feat(core): create `SplitWords` linter (#2118)

Elijah Pottera292474706b5
diff --git a/Cargo.lock b/Cargo.lock
index d098e5c5f..72cb20496 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1973,6 +1973,15 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
+[[package]]
+name = "fid-rs"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6956a1e60e2d1412b44b4169d44a03dae518f8583d3e10090c912c105e48447"
+dependencies = [
+ "rayon",
+]
+
[[package]]
name = "filetime"
version = "0.2.26"
@@ -2735,6 +2744,7 @@ dependencies = [
"strum",
"strum_macros",
"thiserror 2.0.17",
+ "trie-rs",
"unicode-blocks",
"unicode-script",
"unicode-width 0.2.2",
@@ -3445,6 +3455,15 @@ version = "0.4.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
+[[package]]
+name = "louds-rs"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "936de6c22f08e7135a921f8ada907acd0d88880c4f42b5591f634b9f1dd8e07f"
+dependencies = [
+ "fid-rs",
+]
+
[[package]]
name = "lru"
version = "0.16.2"
@@ -5944,6 +5963,15 @@ dependencies = [
"tree-sitter-language",
]
+[[package]]
+name = "trie-rs"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6f88f4b0a1ebd6c3d16be3e45eb0e8089372ccadd88849b7ca162ba64b5e6f6"
+dependencies = [
+ "louds-rs",
+]
+
[[package]]
name = "try-lock"
version = "0.2.5"
diff --git a/harper-cli/src/main.rs b/harper-cli/src/main.rs
index 57dea687d..a4e636859 100644
--- a/harper-cli/src/main.rs
+++ b/harper-cli/src/main.rs
@@ -369,7 +369,7 @@ fn main() -> anyhow::Result<()> {
Args::Metadata { words } => {
let mut results = BTreeMap::new();
for word in words {
- let metadata = dictionary.get_lexeme_metadata_str(&word);
+ let metadata = dictionary.get_word_metadata_str(&word);
results.insert(word, metadata);
}
let json = serde_json::to_string_pretty(&results).unwrap();
@@ -729,7 +729,7 @@ fn main() -> anyhow::Result<()> {
let mut processed_words = HashMap::new();
let mut longest_word = 0;
for word in dictionary.words_iter() {
- if let Some(metadata) = dictionary.get_lexeme_metadata(word) {
+ if let Some(metadata) = dictionary.get_word_metadata(word) {
let orth = metadata.orth_info;
let bits = orth.bits() & case_bitmask.bits();
@@ -859,7 +859,7 @@ fn print_word_derivations(word: &str, annot: &str, dictionary: &impl Dictionary)
let children = dictionary
.words_iter()
- .filter(|e| dictionary.get_lexeme_metadata(e).unwrap().derived_from == Some(id));
+ .filter(|e| dictionary.get_word_metadata(e).unwrap().derived_from == Some(id));
println!(" - {word}");
diff --git a/harper-comments/tests/language_support.rs b/harper-comments/tests/language_support.rs
index f5388e381..3a87d23ca 100644
--- a/harper-comments/tests/language_support.rs
+++ b/harper-comments/tests/language_support.rs
@@ -41,9 +41,9 @@ macro_rules! create_test {
};
}
-create_test!(multiline_comments.cpp, 3);
-create_test!(multiline_comments.ts, 3);
-create_test!(multiline_comments.sol, 3);
+create_test!(multiline_comments.cpp, 4);
+create_test!(multiline_comments.ts, 4);
+create_test!(multiline_comments.sol, 4);
create_test!(clean.lua, 0);
create_test!(dirty.lua, 1);
create_test!(clean.rs, 0);
diff --git a/harper-core/Cargo.toml b/harper-core/Cargo.toml
index 008abe42b..ad494e1f1 100644
--- a/harper-core/Cargo.toml
+++ b/harper-core/Cargo.toml
@@ -33,6 +33,7 @@ strum = "0.27.2"
ammonia = "4.1.2"
harper-brill = { path = "../harper-brill", version = "0.70.0" }
bitflags = { version = "2.10.0", features = ["serde"] }
+trie-rs = "0.4.2"
[dev-dependencies]
criterion = { version = "0.7.0", default-features = false }
@@ -43,7 +44,7 @@ once_cell = "1.21.3"
rayon = "1.11.0"
[[bench]]
-name = "parse_demo"
+name = "parse_essay"
harness = false
[features]
diff --git a/harper-core/benches/parse_demo.rs b/harper-core/benches/parse_essay.rs
similarity index 100%
rename from harper-core/benches/parse_demo.rs
rename to harper-core/benches/parse_essay.rs
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dict
index 1492968a0..c8ee4038a 100644
--- a/harper-core/dictionary.dict
+++ b/harper-core/dictionary.dict
@@ -16072,7 +16072,7 @@ byway/~NSg
byword/NSg
byzantine/~JN
c/~NSViE
-ca/~P
+ca/P
cab/~NSgV>Z
cabal/~NgSV
cabala's
@@ -20168,7 +20168,7 @@ czar/~NgS
czarina/NSg
czarism/N
czarist/NSg
-d/~JGnXz
+d/JGnXz
d'Arezzo/g
d'Estaing/g
dB/
@@ -23378,7 +23378,7 @@ equivocalness/Nmg
equivocate/VGdSnX
equivocation/Nmg
equivocator/NSg
-er/~VNe
+er/VNe
era/~NSg
eradicable/Ji
eradicate/~VdSGn
@@ -24829,7 +24829,7 @@ fizz/NgSVdG
fizzle/VdGNSg
fizzy/J>^N
fjord/~NSg
-fl/~JdGz
+fl/JdGz
flab/Ng
flabbergast/VGdNS
flabbily/R
@@ -30928,7 +30928,7 @@ jutting/VN
juvenile/~JNSg
juxtapose/VdSG
juxtaposition/~NSgV
-k/~NSiW
+k/NSiW
kHz/
kW/
kWh/
@@ -31265,7 +31265,7 @@ kvetch/VGd>NgSZ
kvetcher/Ng
kw/~
l/~NSd^GXz
-la/~NgJ
+la/NgJ
lab/~NSg
label/~NSVdG>r
label's
@@ -32176,10 +32176,10 @@ livid/JY
living/~VJNgS
lix/K
lizard/~NgS
-ll/~N
+ll/N
llama/NSg
llano/NSg
-lo/~JN
+lo/JN
load/~NwSVGdrU
load's
loadable/J
@@ -32592,7 +32592,7 @@ lyricism/Nmg
lyricist/~NSg
lysosomal/J
lysosomes/N
-m/~JNSVKr
+m/JNSVKr
mRNA/Nmg
mTOR # mammalian target of rapamycin
ma/~NSgH
@@ -33190,7 +33190,6 @@ matrimonial/~JN
matrimony/Nmg
matrix/~N0g
matron/~NgSY
-matt/JNSV!_
matte/~NSgJdGZ
matter/~NwSgVdG
matting/NgV
@@ -34986,7 +34985,7 @@ mythology/~NwSg
mythos/Nmg
myths/~N9
myxomatosis/Nmg
-n/~NJ^CiKH
+n/NJ^CiKH
naan/NwS
nab/VNS
nabbed/V
@@ -36123,7 +36122,7 @@ oath/~NgV
oaths/~NV
oatmeal/NgJ
oats/~N9wg
-ob/~NS
+ob/NS
obbligato/NgS
obduracy/Ng
obdurate/JYVp
@@ -41215,7 +41214,7 @@ razz/NgSVGd
razzmatazz/Ng
rcpt/N
rd/~N
-re/~PNSgvz
+re/PNSgvz
reach/~VdGNgSB
reachable/~JNU
reacquire/VdSG
@@ -41709,7 +41708,7 @@ relocate/~VB
reluctance/~Ng
reluctant/~JY
rely/~VGdS
-rem/~NgJ
+rem/NgJ
remain/~NSVGd
remainder/~NgSJVGd
remand/~NSVGd
@@ -47594,7 +47593,7 @@ systemize/VGdS
systemwide/J
systole/NSg
systolic/JN
-t/~NSdGnXBz
+t/NSdGnXBz
ta/~PN
tab/~NSgV
tabbed/JVtT
@@ -50639,7 +50638,7 @@ uveitis/N
uvula/NSg
uvular/JNgS
uxorious/J
-v/~NSPr
+v/NSPr
vac/NSV
vacancy/~NwSg
vacant/~JY
@@ -52679,7 +52678,7 @@ yup/NSg
yuppie/NgS
yuppify/VGdS
yurt/NgS
-z/~d^GnXz
+z/d^GnXz
zaniness/Nmg
zany/J^NSgV>p
zap/~NSgV
diff --git a/harper-core/src/dict_word_metadata.rs b/harper-core/src/dict_word_metadata.rs
index 3222cc596..baa6d1046 100644
--- a/harper-core/src/dict_word_metadata.rs
+++ b/harper-core/src/dict_word_metadata.rs
@@ -5,7 +5,7 @@ use paste::paste;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use strum::{EnumCount as _, VariantArray as _};
-use strum_macros::{Display, EnumCount, EnumString, VariantArray};
+use strum_macros::{Display, EnumCount, EnumIter, EnumString, VariantArray};
use std::convert::TryFrom;
@@ -964,6 +964,7 @@ impl ConjunctionData {
Hash,
EnumCount,
EnumString,
+ EnumIter,
Display,
VariantArray,
)]
@@ -1143,7 +1144,7 @@ pub mod tests {
// Helper function to get metadata from the curated dictionary
pub fn md(word: &str) -> DictWordMetadata {
FstDictionary::curated()
- .get_lexeme_metadata_str(word)
+ .get_word_metadata_str(word)
.unwrap_or_else(|| panic!("Word '{word}' not found in dictionary"))
.into_owned()
}
diff --git a/harper-core/src/document.rs b/harper-core/src/document.rs
index 3244c3313..c658a70ba 100644
--- a/harper-core/src/document.rs
+++ b/harper-core/src/document.rs
@@ -164,7 +164,7 @@ impl Document {
if let TokenKind::Word(meta) = &mut token.kind {
let word_source = token.span.get_content(&self.source);
let mut found_meta = dictionary
- .get_lexeme_metadata(word_source)
+ .get_word_metadata(word_source)
.map(|c| c.into_owned());
if let Some(inner) = &mut found_meta {
diff --git a/harper-core/src/expr/mergeable_words.rs b/harper-core/src/expr/mergeable_words.rs
index 8cdab83b7..a37ff5f09 100644
--- a/harper-core/src/expr/mergeable_words.rs
+++ b/harper-core/src/expr/mergeable_words.rs
@@ -49,11 +49,11 @@ impl MergeableWords {
let mut compound = a_chars.clone();
compound.push(' ');
compound.extend_from_slice(&b_chars);
- let meta_open = self.dict.get_lexeme_metadata(&compound);
+ let meta_open = self.dict.get_word_metadata(&compound);
// Then check if the closed compound exists in the dictionary
compound.remove(a_chars.len());
- let meta_closed = self.dict.get_lexeme_metadata(&compound);
+ let meta_closed = self.dict.get_word_metadata(&compound);
if (self.predicate)(meta_closed.as_deref(), meta_open.as_deref()) {
return Some(compound);
diff --git a/harper-core/src/linting/inflected_verb_after_to.rs b/harper-core/src/linting/inflected_verb_after_to.rs
index 0f821be75..41ab1f1c5 100644
--- a/harper-core/src/linting/inflected_verb_after_to.rs
+++ b/harper-core/src/linting/inflected_verb_after_to.rs
@@ -42,7 +42,7 @@ impl<T: Dictionary> Linter for InflectedVerbAfterTo<T> {
}
let check_stem = |stem: &[char]| {
- if let Some(metadata) = self.dictionary.get_lexeme_metadata(stem)
+ if let Some(metadata) = self.dictionary.get_word_metadata(stem)
&& metadata.is_verb()
&& !metadata.is_noun()
{
@@ -79,7 +79,7 @@ impl<T: Dictionary> Linter for InflectedVerbAfterTo<T> {
let ed_specific_heuristics = || {
if let Some(prev) = document.get_next_word_from_offset(pi, -1) {
let prev_chars = document.get_span_content(&prev.span);
- if let Some(metadata) = self.dictionary.get_lexeme_metadata(prev_chars) {
+ if let Some(metadata) = self.dictionary.get_word_metadata(prev_chars) {
// adj: "able to" expects an infinitive verb
// verb: "have/had/has/having to" expect an infinitive verb
if metadata.is_adjective() || metadata.is_verb() {
diff --git a/harper-core/src/linting/lint_group.rs b/harper-core/src/linting/lint_group.rs
index 6a122bbb1..4f11b83ed 100644
--- a/harper-core/src/linting/lint_group.rs
+++ b/harper-core/src/linting/lint_group.rs
@@ -125,6 +125,7 @@ use super::sought_after::SoughtAfter;
use super::spaces::Spaces;
use super::spell_check::SpellCheck;
use super::spelled_numbers::SpelledNumbers;
+use super::split_words::SplitWords;
use super::that_than::ThatThan;
use super::that_which::ThatWhich;
use super::the_how_why::TheHowWhy;
@@ -491,6 +492,7 @@ impl LintGroup {
insert_struct_rule!(LongSentences, true);
insert_expr_rule!(LookingForwardTo, true);
insert_struct_rule!(MergeWords, true);
+ insert_expr_rule!(SplitWords, true);
insert_expr_rule!(Misspell, true);
insert_expr_rule!(MissingPreposition, true);
insert_expr_rule!(MissingTo, true);
diff --git a/harper-core/src/linting/mass_plurals.rs b/harper-core/src/linting/mass_plurals.rs
index 45d971131..b4507de47 100644
--- a/harper-core/src/linting/mass_plurals.rs
+++ b/harper-core/src/linting/mass_plurals.rs
@@ -42,13 +42,13 @@ where
fn is_mass_noun_in_dictionary(&self, chars: &[char]) -> bool {
self.dict
- .get_lexeme_metadata(chars)
+ .get_word_metadata(chars)
.is_some_and(|wmd| wmd.is_mass_noun_only())
}
fn is_mass_noun_in_dictionary_str(&self, s: &str) -> bool {
self.dict
- .get_lexeme_metadata_str(s)
+ .get_word_metadata_str(s)
.is_some_and(|wmd| wmd.is_mass_noun_only())
}
}
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index 887936e88..60fec21c9 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -138,6 +138,7 @@ mod sought_after;
mod spaces;
mod spell_check;
mod spelled_numbers;
+mod split_words;
mod suggestion;
mod take_serious;
mod that_than;
@@ -287,6 +288,7 @@ pub use sought_after::SoughtAfter;
pub use spaces::Spaces;
pub use spell_check::SpellCheck;
pub use spelled_numbers::SpelledNumbers;
+pub use split_words::SplitWords;
pub use suggestion::Suggestion;
pub use take_serious::TakeSerious;
pub use that_than::ThatThan;
diff --git a/harper-core/src/linting/phrasal_verb_as_compound_noun.rs b/harper-core/src/linting/phrasal_verb_as_compound_noun.rs
index 2349812b9..1f962f725 100644
--- a/harper-core/src/linting/phrasal_verb_as_compound_noun.rs
+++ b/harper-core/src/linting/phrasal_verb_as_compound_noun.rs
@@ -103,10 +103,10 @@ impl Linter for PhrasalVerbAsCompoundNoun {
// So far we only have a small number of phrasal verbs in the dictionary.
let (verb_part_is_verb, phrasal_verb_is_verb) = (
self.dict
- .get_lexeme_metadata(verb_part)
+ .get_word_metadata(verb_part)
.is_some_and(|md| md.verb.is_some()),
self.dict
- .get_lexeme_metadata_str(&phrasal_verb)
+ .get_word_metadata_str(&phrasal_verb)
.is_some_and(|md| md.verb.is_some()),
);
diff --git a/harper-core/src/linting/spell_check.rs b/harper-core/src/linting/spell_check.rs
index cb40662c2..a098c1339 100644
--- a/harper-core/src/linting/spell_check.rs
+++ b/harper-core/src/linting/spell_check.rs
@@ -14,7 +14,7 @@ where
T: Dictionary,
{
dictionary: T,
- word_cache: LruCache<CharString, Vec<CharString>>,
+ suggestion_cache: LruCache<CharString, Vec<CharString>>,
dialect: Dialect,
}
@@ -22,7 +22,7 @@ impl<T: Dictionary> SpellCheck<T> {
pub fn new(dictionary: T, dialect: Dialect) -> Self {
Self {
dictionary,
- word_cache: LruCache::new(NonZero::new(10000).unwrap()),
+ suggestion_cache: LruCache::new(NonZero::new(10000).unwrap()),
dialect,
}
}
@@ -30,11 +30,11 @@ impl<T: Dictionary> SpellCheck<T> {
const MAX_SUGGESTIONS: usize = 3;
fn suggest_correct_spelling(&mut self, word: &[char]) -> Vec<CharString> {
- if let Some(hit) = self.word_cache.get(word) {
+ if let Some(hit) = self.suggestion_cache.get(word) {
hit.clone()
} else {
let suggestions = self.uncached_suggest_correct_spelling(word);
- self.word_cache.put(word.into(), suggestions.clone());
+ self.suggestion_cache.put(word.into(), suggestions.clone());
suggestions
}
}
@@ -45,9 +45,9 @@ impl<T: Dictionary> SpellCheck<T> {
suggest_correct_spelling(word, 100, dist, &self.dictionary)
.into_iter()
.filter(|v| {
- // ignore entries outside the configured dialect
+ // Ignore entries outside the configured dialect
self.dictionary
- .get_lexeme_metadata(v)
+ .get_word_metadata(v)
.unwrap()
.dialects
.is_dialect_enabled(self.dialect)
@@ -92,15 +92,16 @@ impl<T: Dictionary> Linter for SpellCheck<T> {
}
}
- let suggestions = possibilities
+ let suggestions: Vec<_> = possibilities
.iter()
- .map(|word| Suggestion::ReplaceWith(word.to_vec()));
+ .map(|sug| Suggestion::ReplaceWith(sug.to_vec()))
+ .collect();
// If there's only one suggestion, save the user a step in the GUI
let message = if suggestions.len() == 1 {
format!(
"Did you mean `{}`?",
- possibilities.last().unwrap().iter().collect::<String>()
+ possibilities.first().unwrap().iter().collect::<String>()
)
} else {
format!(
@@ -112,7 +113,7 @@ impl<T: Dictionary> Linter for SpellCheck<T> {
lints.push(Lint {
span: word.span,
lint_kind: LintKind::Spelling,
- suggestions: suggestions.collect(),
+ suggestions,
message,
priority: 63,
})
@@ -128,9 +129,12 @@ impl<T: Dictionary> Linter for SpellCheck<T> {
#[cfg(test)]
mod tests {
+ use strum::IntoEnumIterator;
+
use super::SpellCheck;
use crate::dict_word_metadata::DialectFlags;
use crate::linting::Linter;
+ use crate::linting::tests::assert_no_lints;
use crate::spell::{Dictionary, FstDictionary, MergedDictionary, MutableDictionary};
use crate::{
Dialect,
@@ -217,7 +221,7 @@ mod tests {
}
#[test]
- fn austrlaian_verandah_in_british_dialect() {
+ fn australian_verandah_in_british_dialect() {
assert_lint_count(
"Our house has a verandah.",
SpellCheck::new(FstDictionary::curated(), Dialect::British),
@@ -450,4 +454,15 @@ mod tests {
1
);
}
+
+ #[test]
+ fn matt_is_allowed() {
+ for dialect in Dialect::iter() {
+ dbg!(dialect);
+ assert_no_lints(
+ "Matt is a great name.",
+ SpellCheck::new(FstDictionary::curated(), dialect),
+ );
+ }
+ }
}
diff --git a/harper-core/src/linting/split_words.rs b/harper-core/src/linting/split_words.rs
new file mode 100644
index 000000000..61cfc6c96
--- /dev/null
+++ b/harper-core/src/linting/split_words.rs
@@ -0,0 +1,164 @@
+use crate::spell::Dictionary;
+use std::sync::Arc;
+
+use crate::Token;
+use crate::expr::Expr;
+use crate::linting::{LintKind, Suggestion};
+use crate::spell::{FstDictionary, TrieDictionary};
+
+use super::{ExprLinter, Lint};
+
+pub struct SplitWords {
+ dict: Arc<TrieDictionary<Arc<FstDictionary>>>,
+ expr: Box<dyn Expr>,
+}
+
+impl SplitWords {
+ pub fn new() -> Self {
+ Self {
+ dict: TrieDictionary::curated(),
+ expr: Box::new(|tok: &Token, _: &[char]| tok.kind.is_word()),
+ }
+ }
+}
+
+impl Default for SplitWords {
+ fn default() -> Self {
+ Self::new()
+ }
+}
+
+impl ExprLinter for SplitWords {
+ fn description(&self) -> &str {
+ "Finds missing spaces in improper compound words."
+ }
+
+ fn expr(&self) -> &dyn Expr {
+ self.expr.as_ref()
+ }
+
+ fn match_to_lint(&self, matched_tokens: &[Token], source: &[char]) -> Option<Lint> {
+ let word = &matched_tokens[0];
+
+ // If it's a recognized word, we don't care about it.
+ if word.kind.as_word().unwrap().is_some() {
+ return None;
+ }
+
+ let chars = &word.span.get_content(source);
+ // The word that starts the compound
+ let candidates = self.dict.find_words_with_common_prefix(chars);
+
+ for candidate in candidates {
+ if candidate.len() >= chars.len() {
+ continue;
+ }
+
+ let cand_meta = self.dict.get_word_metadata(&candidate).unwrap();
+ if !cand_meta.common {
+ continue;
+ }
+
+ // The potential word that completes the compound
+ let remainder = &chars[candidate.len()..];
+ if let Some(rem_meta) = self.dict.get_word_metadata(remainder)
+ && rem_meta.common
+ {
+ let candidate_chars = candidate.as_ref();
+ let mut suggestion = Vec::new();
+
+ suggestion.extend(candidate_chars.iter());
+ suggestion.push(' ');
+ suggestion.extend(remainder.iter());
+
+ let original_word: String = chars.iter().collect();
+ let candidate_word: String = candidate_chars.iter().collect();
+ let remainder_word: String = remainder.iter().collect();
+
+ return Some(Lint {
+ span: word.span,
+ lint_kind: LintKind::Typo,
+ suggestions: vec![Suggestion::ReplaceWith(suggestion)],
+ message: format!(
+ "`{original_word}` should probably be written as `{candidate_word} {remainder_word}`."
+ ),
+ priority: 31,
+ });
+ }
+ }
+
+ None
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::linting::tests::{assert_no_lints, assert_suggestion_result};
+
+ use super::SplitWords;
+
+ #[test]
+ fn issue_1905() {
+ assert_suggestion_result(
+ "I want to try this insteadof that.",
+ SplitWords::default(),
+ "I want to try this instead of that.",
+ );
+ }
+
+ /// Same as above, but with the longer component word at the end.
+ #[test]
+ fn issue_1905_rev() {
+ assert_suggestion_result(
+ "I want to try thisinstead of that.",
+ SplitWords::default(),
+ "I want to try this instead of that.",
+ );
+ }
+
+ #[test]
+ fn split_common() {
+ assert_suggestion_result(
+ "This is notnot a problem.",
+ SplitWords::default(),
+ "This is not not a problem.",
+ );
+ }
+
+ #[test]
+ fn splits_multiple_compound_words() {
+ assert_suggestion_result(
+ "We stared intothe darkness and kindof panicked about sortof everything.",
+ SplitWords::default(),
+ "We stared into the darkness and kind of panicked about sort of everything.",
+ );
+ }
+
+ #[test]
+ fn splits_word_with_longer_prefix() {
+ assert_suggestion_result(
+ "The astronauts waited on the landingpad for hours.",
+ SplitWords::default(),
+ "The astronauts waited on the landing pad for hours.",
+ );
+ }
+
+ #[test]
+ fn splits_before_punctuation() {
+ assert_suggestion_result(
+ "This was kindof, actually, hilarious.",
+ SplitWords::default(),
+ "This was kind of, actually, hilarious.",
+ );
+ }
+
+ #[test]
+ fn ignores_known_compound_words() {
+ assert_no_lints("Someone left early.", SplitWords::default());
+ }
+
+ #[test]
+ fn ignores_prefix_without_valid_remainder() {
+ assert_no_lints("The monkeyxyz escaped unnoticed.", SplitWords::default());
+ }
+}
diff --git a/harper-core/src/spell/dictionary.rs b/harper-core/src/spell/dictionary.rs
index 50a263b0c..3c74f530b 100644
--- a/harper-core/src/spell/dictionary.rs
+++ b/harper-core/src/spell/dictionary.rs
@@ -34,11 +34,11 @@ pub trait Dictionary: Send + Sync {
) -> Vec<FuzzyMatchResult<'_>>;
fn get_correct_capitalization_of(&self, word: &[char]) -> Option<&'_ [char]>;
/// Get the associated [`DictWordMetadata`] for any capitalization of a given word.
- fn get_lexeme_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>>;
+ fn get_word_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>>;
/// Get the associated [`DictWordMetadata`] for any capitalization of a given word.
/// If the word isn't in the dictionary, the resulting metadata will be
/// empty.
- fn get_lexeme_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>>;
+ fn get_word_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>>;
/// Iterate over the words in the dictionary.
fn words_iter(&self) -> Box<dyn Iterator<Item = &'_ [char]> + Send + '_>;
@@ -48,4 +48,10 @@ pub trait Dictionary: Send + Sync {
/// Returns the correct capitalization of the word with the given ID.
fn get_word_from_id(&self, id: &WordId) -> Option<&[char]>;
+
+ /// Look for words with a specific prefix
+ fn find_words_with_prefix(&self, prefix: &[char]) -> Vec<Cow<'_, [char]>>;
+
+ /// Look for words that share a prefix with the provided word
+ fn find_words_with_common_prefix(&self, word: &[char]) -> Vec<Cow<'_, [char]>>;
}
diff --git a/harper-core/src/spell/fst_dictionary.rs b/harper-core/src/spell/fst_dictionary.rs
index 23f917253..e64d0f3e2 100644
--- a/harper-core/src/spell/fst_dictionary.rs
+++ b/harper-core/src/spell/fst_dictionary.rs
@@ -54,7 +54,7 @@ impl FstDictionary {
(*DICT).clone()
}
- /// Construct a new [`FstDictionary`] using a word list as a source.
+ /// Construct a new [`FstDictionary`] using a wordlist as a source.
/// This can be expensive, so only use this if fast fuzzy searches are worth it.
pub fn new(mut words: Vec<(CharString, DictWordMetadata)>) -> Self {
words.sort_unstable_by(|(a, _), (b, _)| a.cmp(b));
@@ -121,12 +121,12 @@ impl Dictionary for FstDictionary {
self.mutable_dict.contains_word_str(word)
}
- fn get_lexeme_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>> {
- self.mutable_dict.get_lexeme_metadata(word)
+ fn get_word_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>> {
+ self.mutable_dict.get_word_metadata(word)
}
- fn get_lexeme_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>> {
- self.mutable_dict.get_lexeme_metadata_str(word)
+ fn get_word_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>> {
+ self.mutable_dict.get_word_metadata_str(word)
}
fn fuzzy_match(
@@ -213,6 +213,14 @@ impl Dictionary for FstDictionary {
fn get_word_from_id(&self, id: &WordId) -> Option<&[char]> {
self.mutable_dict.get_word_from_id(id)
}
+
+ fn find_words_with_prefix(&self, prefix: &[char]) -> Vec<Cow<'_, [char]>> {
+ self.mutable_dict.find_words_with_prefix(prefix)
+ }
+
+ fn find_words_with_common_prefix(&self, word: &[char]) -> Vec<Cow<'_, [char]>> {
+ self.mutable_dict.find_words_with_common_prefix(word)
+ }
}
#[cfg(test)]
@@ -283,7 +291,7 @@ mod tests {
fn on_is_not_nominal() {
let dict = FstDictionary::curated();
- assert!(!dict.get_lexeme_metadata_str("on").unwrap().is_nominal());
+ assert!(!dict.get_word_metadata_str("on").unwrap().is_nominal());
}
#[test]
@@ -316,7 +324,7 @@ mod tests {
for contraction in contractions {
dbg!(contraction);
assert!(
- dict.get_lexeme_metadata_str(contraction)
+ dict.get_word_metadata_str(contraction)
.unwrap()
.derived_from
.is_none()
@@ -329,7 +337,7 @@ mod tests {
let dict = FstDictionary::curated();
assert_eq!(
- dict.get_lexeme_metadata_str("llamas")
+ dict.get_word_metadata_str("llamas")
.unwrap()
.derived_from
.unwrap(),
@@ -342,7 +350,7 @@ mod tests {
let dict = FstDictionary::curated();
assert_eq!(
- dict.get_lexeme_metadata_str("cats")
+ dict.get_word_metadata_str("cats")
.unwrap()
.derived_from
.unwrap(),
@@ -355,7 +363,7 @@ mod tests {
let dict = FstDictionary::curated();
assert_eq!(
- dict.get_lexeme_metadata_str("unhappy")
+ dict.get_word_metadata_str("unhappy")
.unwrap()
.derived_from
.unwrap(),
@@ -368,7 +376,7 @@ mod tests {
let dict = FstDictionary::curated();
assert_eq!(
- dict.get_lexeme_metadata_str("quickly")
+ dict.get_word_metadata_str("quickly")
.unwrap()
.derived_from
.unwrap(),
diff --git a/harper-core/src/spell/merged_dictionary.rs b/harper-core/src/spell/merged_dictionary.rs
index 06c8cd8b6..be70b061c 100644
--- a/harper-core/src/spell/merged_dictionary.rs
+++ b/harper-core/src/spell/merged_dictionary.rs
@@ -94,10 +94,10 @@ impl Dictionary for MergedDictionary {
false
}
- fn get_lexeme_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>> {
+ fn get_word_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>> {
self.children
.iter()
- .filter_map(|d| d.get_lexeme_metadata(word))
+ .filter_map(|d| d.get_word_metadata(word))
.reduce(|acc, md| Cow::Owned(acc.or(&md)))
}
@@ -115,9 +115,9 @@ impl Dictionary for MergedDictionary {
self.contains_word(&chars)
}
- fn get_lexeme_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>> {
+ fn get_word_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>> {
let chars: CharString = word.chars().collect();
- self.get_lexeme_metadata(&chars)
+ self.get_word_metadata(&chars)
}
fn fuzzy_match(
@@ -157,4 +157,22 @@ impl Dictionary for MergedDictionary {
.iter()
.find_map(|dict| dict.get_word_from_id(id))
}
+
+ fn find_words_with_prefix(&self, prefix: &[char]) -> Vec<Cow<'_, [char]>> {
+ self.children
+ .iter()
+ .flat_map(|dict| dict.find_words_with_prefix(prefix))
+ .sorted()
+ .dedup()
+ .collect()
+ }
+
+ fn find_words_with_common_prefix(&self, word: &[char]) -> Vec<Cow<'_, [char]>> {
+ self.children
+ .iter()
+ .flat_map(|dict| dict.find_words_with_common_prefix(word))
+ .sorted()
+ .dedup()
+ .collect()
+ }
}
diff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rs
index 3d049926e..9e1838679 100644
--- a/harper-core/src/spell/mod.rs
+++ b/harper-core/src/spell/mod.rs
@@ -7,6 +7,7 @@ pub use self::dictionary::Dictionary;
pub use self::fst_dictionary::FstDictionary;
pub use self::merged_dictionary::MergedDictionary;
pub use self::mutable_dictionary::MutableDictionary;
+pub use self::trie_dictionary::TrieDictionary;
pub use self::word_id::WordId;
mod dictionary;
@@ -14,6 +15,7 @@ mod fst_dictionary;
mod merged_dictionary;
mod mutable_dictionary;
mod rune;
+mod trie_dictionary;
mod word_id;
mod word_map;
diff --git a/harper-core/src/spell/mutable_dictionary.rs b/harper-core/src/spell/mutable_dictionary.rs
index 1dca6eeb5..debf7afb8 100644
--- a/harper-core/src/spell/mutable_dictionary.rs
+++ b/harper-core/src/spell/mutable_dictionary.rs
@@ -17,7 +17,7 @@ use super::dictionary::Dictionary;
/// A basic dictionary that allows words to be added after instantiating.
/// This is useful for user and file dictionaries that may change at runtime.
///
-/// For immutable use-cases, such as the curated dictionary, prefer [`super::FstDictionary`],
+/// For immutable use-cases that require fuzzy lookups, such as the curated dictionary, prefer [`super::FstDictionary`],
/// as it is much faster.
///
/// To combine the contents of multiple dictionaries, regardless of type, use
@@ -108,7 +108,7 @@ impl Default for MutableDictionary {
}
impl Dictionary for MutableDictionary {
- fn get_lexeme_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>> {
+ fn get_word_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>> {
self.word_map
.get_with_chars(word)
.map(|v| Cow::Borrowed(&v.metadata))
@@ -123,9 +123,9 @@ impl Dictionary for MutableDictionary {
self.contains_word(&chars)
}
- fn get_lexeme_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>> {
+ fn get_word_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>> {
let chars: CharString = word.chars().collect();
- self.get_lexeme_metadata(&chars)
+ self.get_word_metadata(&chars)
}
fn get_correct_capitalization_of(&self, word: &[char]) -> Option<&'_ [char]> {
@@ -188,7 +188,7 @@ impl Dictionary for MutableDictionary {
.map(|(word, edit_distance)| FuzzyMatchResult {
word,
edit_distance,
- metadata: self.get_lexeme_metadata(word).unwrap(),
+ metadata: self.get_word_metadata(word).unwrap(),
})
.collect()
}
@@ -235,6 +235,34 @@ impl Dictionary for MutableDictionary {
fn get_word_from_id(&self, id: &WordId) -> Option<&[char]> {
self.word_map.get(id).map(|w| w.canonical_spelling.as_ref())
}
+
+ fn find_words_with_prefix(&self, prefix: &[char]) -> Vec<Cow<'_, [char]>> {
+ let mut found = Vec::new();
+
+ for word in self.words_iter() {
+ if let Some(item_prefix) = word.get(0..prefix.len())
+ && item_prefix == prefix
+ {
+ found.push(Cow::Borrowed(word));
+ }
+ }
+
+ found
+ }
+
+ fn find_words_with_common_prefix(&self, word: &[char]) -> Vec<Cow<'_, [char]>> {
+ let mut found = Vec::new();
+
+ for item in self.words_iter() {
+ if let Some(item_prefix) = word.get(0..item.len())
+ && item_prefix == item
+ {
+ found.push(Cow::Borrowed(item));
+ }
+ }
+
+ found
+ }
}
impl From<MutableDictionary> for FstDictionary {
@@ -251,10 +279,13 @@ impl From<MutableDictionary> for FstDictionary {
#[cfg(test)]
mod tests {
+ use std::borrow::Cow;
+
use hashbrown::HashSet;
use itertools::Itertools;
use crate::spell::{Dictionary, MutableDictionary};
+ use crate::{DictWordMetadata, char_string::char_string};
#[test]
fn curated_contains_no_duplicates() {
@@ -275,23 +306,15 @@ mod tests {
#[test]
fn this_is_determiner() {
let dict = MutableDictionary::curated();
- assert!(
- dict.get_lexeme_metadata_str("this")
- .unwrap()
- .is_determiner()
- );
- assert!(
- dict.get_lexeme_metadata_str("This")
- .unwrap()
- .is_determiner()
- );
+ assert!(dict.get_word_metadata_str("this").unwrap().is_determiner());
+ assert!(dict.get_word_metadata_str("This").unwrap().is_determiner());
}
#[test]
fn several_is_quantifier() {
let dict = MutableDictionary::curated();
assert!(
- dict.get_lexeme_metadata_str("several")
+ dict.get_word_metadata_str("several")
.unwrap()
.is_quantifier()
);
@@ -300,47 +323,27 @@ mod tests {
#[test]
fn few_is_quantifier() {
let dict = MutableDictionary::curated();
- assert!(dict.get_lexeme_metadata_str("few").unwrap().is_quantifier());
+ assert!(dict.get_word_metadata_str("few").unwrap().is_quantifier());
}
#[test]
fn fewer_is_quantifier() {
let dict = MutableDictionary::curated();
- assert!(
- dict.get_lexeme_metadata_str("fewer")
- .unwrap()
- .is_quantifier()
- );
+ assert!(dict.get_word_metadata_str("fewer").unwrap().is_quantifier());
}
#[test]
fn than_is_conjunction() {
let dict = MutableDictionary::curated();
- assert!(
- dict.get_lexeme_metadata_str("than")
- .unwrap()
- .is_conjunction()
- );
- assert!(
- dict.get_lexeme_metadata_str("Than")
- .unwrap()
- .is_conjunction()
- );
+ assert!(dict.get_word_metadata_str("than").unwrap().is_conjunction());
+ assert!(dict.get_word_metadata_str("Than").unwrap().is_conjunction());
}
#[test]
fn herself_is_pronoun() {
let dict = MutableDictionary::curated();
- assert!(
- dict.get_lexeme_metadata_str("herself")
- .unwrap()
- .is_pronoun()
- );
- assert!(
- dict.get_lexeme_metadata_str("Herself")
- .unwrap()
- .is_pronoun()
- );
+ assert!(dict.get_word_metadata_str("herself").unwrap().is_pronoun());
+ assert!(dict.get_word_metadata_str("Herself").unwrap().is_pronoun());
}
#[test]
@@ -352,7 +355,7 @@ mod tests {
#[test]
fn im_is_common() {
let dict = MutableDictionary::curated();
- assert!(dict.get_lexeme_metadata_str("I'm").unwrap().common);
+ assert!(dict.get_word_metadata_str("I'm").unwrap().common);
}
#[test]
@@ -373,8 +376,8 @@ mod tests {
fn there_is_not_a_pronoun() {
let dict = MutableDictionary::curated();
- assert!(!dict.get_lexeme_metadata_str("there").unwrap().is_nominal());
- assert!(!dict.get_lexeme_metadata_str("there").unwrap().is_pronoun());
+ assert!(!dict.get_word_metadata_str("there").unwrap().is_nominal());
+ assert!(!dict.get_word_metadata_str("there").unwrap().is_pronoun());
}
#[test]
@@ -400,7 +403,7 @@ mod tests {
fn curated_contains_possessive_abandonment() {
assert!(
MutableDictionary::curated()
- .get_lexeme_metadata_str("abandonment's")
+ .get_word_metadata_str("abandonment's")
.unwrap()
.is_possessive_noun()
)
@@ -410,7 +413,7 @@ mod tests {
fn has_is_not_a_nominal() {
let dict = MutableDictionary::curated();
- let has = dict.get_lexeme_metadata_str("has");
+ let has = dict.get_word_metadata_str("has");
assert!(has.is_some());
assert!(!has.unwrap().is_nominal())
@@ -420,7 +423,7 @@ mod tests {
fn is_is_linking_verb() {
let dict = MutableDictionary::curated();
- let is = dict.get_lexeme_metadata_str("is");
+ let is = dict.get_word_metadata_str("is");
assert!(is.is_some());
assert!(is.unwrap().is_linking_verb());
@@ -444,16 +447,47 @@ mod tests {
fn apart_is_not_noun() {
let dict = MutableDictionary::curated();
- assert!(!dict.get_lexeme_metadata_str("apart").unwrap().is_noun());
+ assert!(!dict.get_word_metadata_str("apart").unwrap().is_noun());
}
#[test]
fn be_is_verb_lemma() {
let dict = MutableDictionary::curated();
- let is = dict.get_lexeme_metadata_str("be");
+ let is = dict.get_word_metadata_str("be");
assert!(is.is_some());
assert!(is.unwrap().is_verb_lemma());
}
+
+ #[test]
+ fn gets_prefixes_as_expected() {
+ let mut dict = MutableDictionary::new();
+ dict.append_word_str("predict", DictWordMetadata::default());
+ dict.append_word_str("prelude", DictWordMetadata::default());
+ dict.append_word_str("preview", DictWordMetadata::default());
+ dict.append_word_str("dwight", DictWordMetadata::default());
+
+ let with_prefix = dict.find_words_with_prefix(char_string!("pre").as_slice());
+
+ assert_eq!(with_prefix.len(), 3);
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("predict").into_vec())));
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("prelude").into_vec())));
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("preview").into_vec())));
+ }
+
+ #[test]
+ fn gets_common_prefixes_as_expected() {
+ let mut dict = MutableDictionary::new();
+ dict.append_word_str("pre", DictWordMetadata::default());
+ dict.append_word_str("prep", DictWordMetadata::default());
+ dict.append_word_str("dwight", DictWordMetadata::default());
+
+ let with_prefix =
+ dict.find_words_with_common_prefix(char_string!("preposition").as_slice());
+
+ assert_eq!(with_prefix.len(), 2);
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("pre").into_vec())));
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("prep").into_vec())));
+ }
}
diff --git a/harper-core/src/spell/trie_dictionary.rs b/harper-core/src/spell/trie_dictionary.rs
new file mode 100644
index 000000000..f7f6b62a6
--- /dev/null
+++ b/harper-core/src/spell/trie_dictionary.rs
@@ -0,0 +1,156 @@
+use lazy_static::lazy_static;
+use std::borrow::Cow;
+use std::sync::Arc;
+
+use trie_rs::Trie;
+use trie_rs::iter::{Keys, PrefixIter, SearchIter};
+
+use crate::DictWordMetadata;
+
+use super::{Dictionary, FstDictionary, FuzzyMatchResult, WordId};
+
+/// A [`Dictionary`] optimized for pre- and postfix search.
+/// Wraps another dictionary to implement other operations.
+pub struct TrieDictionary<D: Dictionary> {
+ trie: Trie<char>,
+ inner: D,
+}
+
+lazy_static! {
+ static ref DICT: Arc<TrieDictionary<Arc<FstDictionary>>> =
+ Arc::new(TrieDictionary::new(FstDictionary::curated()));
+}
+
+impl TrieDictionary<Arc<FstDictionary>> {
+ /// Create a dictionary from the curated dictionary included
+ /// in the Harper binary.
+ pub fn curated() -> Arc<Self> {
+ (*DICT).clone()
+ }
+}
+
+impl<D: Dictionary> TrieDictionary<D> {
+ pub fn new(inner: D) -> Self {
+ let trie = Trie::from_iter(inner.words_iter());
+
+ Self { inner, trie }
+ }
+}
+
+impl<D: Dictionary> Dictionary for TrieDictionary<D> {
+ fn contains_word(&self, word: &[char]) -> bool {
+ self.inner.contains_word(word)
+ }
+
+ fn contains_word_str(&self, word: &str) -> bool {
+ self.inner.contains_word_str(word)
+ }
+
+ fn contains_exact_word(&self, word: &[char]) -> bool {
+ self.inner.contains_exact_word(word)
+ }
+
+ fn contains_exact_word_str(&self, word: &str) -> bool {
+ self.inner.contains_exact_word_str(word)
+ }
+
+ fn fuzzy_match(
+ &'_ self,
+ word: &[char],
+ max_distance: u8,
+ max_results: usize,
+ ) -> Vec<FuzzyMatchResult<'_>> {
+ self.inner.fuzzy_match(word, max_distance, max_results)
+ }
+
+ fn fuzzy_match_str(
+ &'_ self,
+ word: &str,
+ max_distance: u8,
+ max_results: usize,
+ ) -> Vec<FuzzyMatchResult<'_>> {
+ self.inner.fuzzy_match_str(word, max_distance, max_results)
+ }
+
+ fn get_correct_capitalization_of(&self, word: &[char]) -> Option<&'_ [char]> {
+ self.inner.get_correct_capitalization_of(word)
+ }
+
+ fn get_word_metadata(&self, word: &[char]) -> Option<Cow<'_, DictWordMetadata>> {
+ self.inner.get_word_metadata(word)
+ }
+
+ fn get_word_metadata_str(&self, word: &str) -> Option<Cow<'_, DictWordMetadata>> {
+ self.inner.get_word_metadata_str(word)
+ }
+
+ fn words_iter(&self) -> Box<dyn Iterator<Item = &'_ [char]> + Send + '_> {
+ self.inner.words_iter()
+ }
+
+ fn word_count(&self) -> usize {
+ self.inner.word_count()
+ }
+
+ fn get_word_from_id(&self, id: &WordId) -> Option<&[char]> {
+ self.inner.get_word_from_id(id)
+ }
+
+ fn find_words_with_prefix(&self, prefix: &[char]) -> Vec<Cow<'_, [char]>> {
+ let results: Keys<SearchIter<'_, char, (), Vec<char>, _>> =
+ self.trie.predictive_search(prefix);
+ results.map(Cow::Owned).collect()
+ }
+
+ fn find_words_with_common_prefix(&self, word: &[char]) -> Vec<Cow<'_, [char]>> {
+ let results: Keys<PrefixIter<'_, char, (), Vec<char>, _>> =
+ self.trie.common_prefix_search(word);
+ results.map(Cow::Owned).collect()
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use std::borrow::Cow;
+
+ use crate::DictWordMetadata;
+ use crate::char_string::char_string;
+ use crate::spell::MutableDictionary;
+ use crate::spell::dictionary::Dictionary;
+ use crate::spell::trie_dictionary::TrieDictionary;
+
+ #[test]
+ fn gets_prefixes_as_expected() {
+ let mut inner = MutableDictionary::new();
+ inner.append_word_str("predict", DictWordMetadata::default());
+ inner.append_word_str("prelude", DictWordMetadata::default());
+ inner.append_word_str("preview", DictWordMetadata::default());
+ inner.append_word_str("dwight", DictWordMetadata::default());
+
+ let dict = TrieDictionary::new(inner);
+
+ let with_prefix = dict.find_words_with_prefix(char_string!("pre").as_slice());
+
+ assert_eq!(with_prefix.len(), 3);
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("predict").into_vec())));
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("prelude").into_vec())));
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("preview").into_vec())));
+ }
+
+ #[test]
+ fn gets_common_prefixes_as_expected() {
+ let mut inner = MutableDictionary::new();
+ inner.append_word_str("pre", DictWordMetadata::default());
+ inner.append_word_str("prep", DictWordMetadata::default());
+ inner.append_word_str("dwight", DictWordMetadata::default());
+
+ let dict = TrieDictionary::new(inner);
+
+ let with_prefix =
+ dict.find_words_with_common_prefix(char_string!("preposition").as_slice());
+
+ assert_eq!(with_prefix.len(), 2);
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("pre").into_vec())));
+ assert!(with_prefix.contains(&Cow::Owned(char_string!("prep").into_vec())));
+ }
+}
diff --git a/harper-core/src/title_case.rs b/harper-core/src/title_case.rs
index 13625a8ec..453825abc 100644
--- a/harper-core/src/title_case.rs
+++ b/harper-core/src/title_case.rs
@@ -90,7 +90,7 @@ fn should_capitalize_token(tok: &Token, source: &[char], dict: &impl Dictionary)
let mut metadata = Cow::Borrowed(metadata);
- if let Some(metadata_lower) = dict.get_lexeme_metadata(&chars_lower) {
+ if let Some(metadata_lower) = dict.get_word_metadata(&chars_lower) {
metadata = Cow::Owned(metadata.clone().or(&metadata_lower));
}
diff --git a/harper-core/tests/run_tests.rs b/harper-core/tests/run_tests.rs
index fa3096a81..bb67e7a3b 100644
--- a/harper-core/tests/run_tests.rs
+++ b/harper-core/tests/run_tests.rs
@@ -93,4 +93,4 @@ create_test!(issue_1581.md, 0, Dialect::British);
create_test!(lukas_homework.md, 3, Dialect::American);
// Org mode tests
-create_org_test!(index.org, 32, Dialect::American);
+create_org_test!(index.org, 38, Dialect::American);
diff --git a/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml b/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
index b991bea71..9ab0d22bc 100644
--- a/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
+++ b/harper-core/tests/text/linters/Alice's Adventures in Wonderland.snap.yml
@@ -1148,6 +1148,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 668 | “Sure, it’s an arm, yer honour!” (He pronounced it “arrum.”)
+ | ^~~~~ `arrum` should probably be written as `arr um`.
+Suggest:
+ - Replace with: “arr um”
+
+
+
Lint: Spelling (63 priority)
Message: |
672 | “Sure, it does, yer honour: but it’s an arm for all that.”
@@ -1465,6 +1474,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 961 | her foot, that there was hardly room to open her mouth; but she did it at last,
+ 962 | and managed to swallow a morsel of the lefthand bit.
+ | ^~~~~~~~ `lefthand` should probably be written as `left hand`.
+Suggest:
+ - Replace with: “left hand”
+
+
+
Lint: Readability (127 priority)
Message: |
964 | “Come, my head’s free at last!” said Alice in a tone of delight, which changed
@@ -1583,6 +1602,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 1055 | this size: why, I should frighten them out of their wits!” So she began nibbling
+ 1056 | at the righthand bit again, and did not venture to go near the house till she
+ | ^~~~~~~~~ `righthand` should probably be written as `right hand`.
+Suggest:
+ - Replace with: “right hand”
+
+
+
Lint: Readability (127 priority)
Message: |
1061 | For a minute or two she stood looking at the house, and wondering what to do
@@ -1791,6 +1820,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 1349 | did not like to go nearer till she had nibbled some more of the lefthand bit of
+ | ^~~~~~~~ `lefthand` should probably be written as `left hand`.
+ 1350 | mushroom, and raised herself to about two feet high: even then she walked up
+Suggest:
+ - Replace with: “left hand”
+
+
+
Lint: Readability (127 priority)
Message: |
1356 | There was a table set out under a tree in front of the house, and the March Hare
@@ -3327,6 +3366,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 2490 | > beautiful Soup? Beau—ootiful Soo—oop! Beau—ootiful Soo—oop! Soo—oop of the
+ 2491 | > e—e—evening, Beautiful, beauti—FUL SOUP!”
+ | ^~~~~~ `beauti` should probably be written as `beau ti`.
+Suggest:
+ - Replace with: “beau ti”
+
+
+
Lint: Spelling (63 priority)
Message: |
2490 | > beautiful Soup? Beau—ootiful Soo—oop! Beau—ootiful Soo—oop! Soo—oop of the
diff --git a/harper-core/tests/text/linters/Computer science.snap.yml b/harper-core/tests/text/linters/Computer science.snap.yml
index 3c00f1f5b..be29f3c8a 100644
--- a/harper-core/tests/text/linters/Computer science.snap.yml
+++ b/harper-core/tests/text/linters/Computer science.snap.yml
@@ -46,9 +46,9 @@ Message: |
50 | de Colmar launched the mechanical calculator industry[note 1] when he invented
| ^~ Did you mean to spell `de` this way?
Suggest:
- - Replace with: “d”
- Replace with: “db”
- Replace with: “dc”
+ - Replace with: “dd”
@@ -407,6 +407,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 131 | expression "automatic information" (e.g. "informazione automatica" in Italian)
+ | ^~~~~~~~~~ `automatica` should probably be written as `automatic a`.
+ 132 | or "information and mathematics" are often used, e.g. informatique (French),
+Suggest:
+ - Replace with: “automatic a”
+
+
+
Lint: Spelling (63 priority)
Message: |
132 | or "information and mathematics" are often used, e.g. informatique (French),
@@ -842,9 +852,9 @@ Message: |
262 | The famous P = NP? problem, one of the Millennium Prize Problems, is an open
| ^~ Did you mean to spell `NP` this way?
Suggest:
- - Replace with: “N”
- Replace with: “Nap”
- Replace with: “Nip”
+ - Replace with: “Nu”
@@ -1044,9 +1054,9 @@ Message: |
| ^~ Did you mean to spell `de` this way?
445 | > "high-voltage/low-voltage", etc.).
Suggest:
- - Replace with: “d”
- Replace with: “db”
- Replace with: “dc”
+ - Replace with: “dd”
@@ -1144,6 +1154,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 468 | Boehm's and Jacopini's insight can be further simplified with the use of
+ 469 | goto (which means it is more elementary than structured programming).
+ | ^~~~ `goto` should probably be written as `go to`.
+Suggest:
+ - Replace with: “go to”
+
+
+
Lint: Punctuation (31 priority)
Message: |
490 | the data fields of the object with which they are associated. Thus
diff --git a/harper-core/tests/text/linters/Part-of-speech tagging.snap.yml b/harper-core/tests/text/linters/Part-of-speech tagging.snap.yml
index 628e8efcd..f86547e6f 100644
--- a/harper-core/tests/text/linters/Part-of-speech tagging.snap.yml
+++ b/harper-core/tests/text/linters/Part-of-speech tagging.snap.yml
@@ -90,9 +90,9 @@ Message: |
| ^~ Did you mean to spell `NP` this way?
50 | for singular proper nouns (see the POS tags used in the Brown Corpus). Other
Suggest:
- - Replace with: “N”
- Replace with: “Nap”
- Replace with: “Nip”
+ - Replace with: “Nu”
diff --git a/harper-core/tests/text/linters/The Constitution of the United States.snap.yml b/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
index f92548338..3b8aca5cf 100644
--- a/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
+++ b/harper-core/tests/text/linters/The Constitution of the United States.snap.yml
@@ -172,6 +172,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 63 | one Representative; and until such enumeration shall be made, the State of New
+ 64 | Hampshire shall be entitled to chuse three, Massachusetts eight, Rhode-Island
+ | ^~~~~ `chuse` should probably be written as `ch use`.
+Suggest:
+ - Replace with: “ch use”
+
+
+
Lint: Spelling (63 priority)
Message: |
72 | The House of Representatives shall chuse their Speaker and other Officers; and
@@ -183,6 +193,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 72 | The House of Representatives shall chuse their Speaker and other Officers; and
+ | ^~~~~ `chuse` should probably be written as `ch use`.
+Suggest:
+ - Replace with: “ch use”
+
+
+
Lint: Readability (127 priority)
Message: |
86 | they shall be divided as equally as may be into three Classes. The Seats of the
@@ -238,6 +257,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 103 | The Senate shall chuse their other Officers, and also a President pro tempore,
+ | ^~~~~ `chuse` should probably be written as `ch use`.
+Suggest:
+ - Replace with: “ch use”
+
+
+
Lint: Redundancy (31 priority)
Message: |
103 | The Senate shall chuse their other Officers, and also a President pro tempore,
@@ -260,6 +288,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 103 | The Senate shall chuse their other Officers, and also a President pro tempore,
+ | ^~~~~~~ `tempore` should probably be written as `temp ore`.
+ 104 | in the Absence of the Vice President, or when he shall exercise the Office of
+Suggest:
+ - Replace with: “temp ore”
+
+
+
Lint: Readability (127 priority)
Message: |
112 | Judgment in Cases of impeachment shall not extend further than to removal from
@@ -1028,6 +1066,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 415 | Whenever the President transmits to the President pro tempore of the Senate and
+ | ^~~~~~~ `tempore` should probably be written as `temp ore`.
+ 416 | the Speaker of the House of Representatives his written declaration that he is
+Suggest:
+ - Replace with: “temp ore”
+
+
+
Lint: Readability (127 priority)
Message: |
421 | Whenever the Vice President and a majority of either the principal officers of
@@ -1057,6 +1105,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 422 | the executive departments or of such other body as Congress may by law provide,
+ 423 | transmit to the President pro tempore of the Senate and the Speaker of the
+ | ^~~~~~~ `tempore` should probably be written as `temp ore`.
+Suggest:
+ - Replace with: “temp ore”
+
+
+
Lint: Readability (127 priority)
Message: |
428 | Thereafter, when the President transmits to the President pro tempore of the
@@ -1090,6 +1148,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 428 | Thereafter, when the President transmits to the President pro tempore of the
+ | ^~~~~~~ `tempore` should probably be written as `temp ore`.
+ 429 | Senate and the Speaker of the House of Representatives his written declaration
+Suggest:
+ - Replace with: “temp ore”
+
+
+
Lint: Spelling (63 priority)
Message: |
433 | transmit within four days to the President pro tempore of the Senate and the
@@ -1102,6 +1170,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 433 | transmit within four days to the President pro tempore of the Senate and the
+ | ^~~~~~~ `tempore` should probably be written as `temp ore`.
+ 434 | Speaker of the House of Representatives their written declaration that the
+Suggest:
+ - Replace with: “temp ore”
+
+
+
Lint: Readability (127 priority)
Message: |
437 | purpose if not in session. If the Congress, within twenty-one days after
@@ -1605,8 +1683,8 @@ Message: |
| ^~ Did you mean to spell `V.` this way?
Suggest:
- Replace with: “Vs.”
- - Replace with: “V”
- Replace with: “Vb”
+ - Replace with: “Vi”
diff --git a/harper-core/tests/text/linters/The Great Gatsby.snap.yml b/harper-core/tests/text/linters/The Great Gatsby.snap.yml
index d7b201cbc..c2eb0e3a3 100644
--- a/harper-core/tests/text/linters/The Great Gatsby.snap.yml
+++ b/harper-core/tests/text/linters/The Great Gatsby.snap.yml
@@ -209,6 +209,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 72 | sounded like a great idea. He found the house, a weatherbeaten cardboard
+ | ^~~~~~~~~~~~~ `weatherbeaten` should probably be written as `weather beaten`.
+ 73 | bungalow at eighty a month, but at the last minute the firm ordered him to
+Suggest:
+ - Replace with: “weather beaten”
+
+
+
Lint: Readability (127 priority)
Message: |
74 | Washington, and I went out to the country alone. I had a dog—at least I had him
@@ -304,9 +314,9 @@ Message: |
120 | was a factual imitation of some Hôtel de Ville in Normandy, with a tower on one
| ^~ Did you mean to spell `de` this way?
Suggest:
- - Replace with: “d”
- Replace with: “db”
- Replace with: “dc”
+ - Replace with: “dd”
@@ -617,6 +627,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 529 | the whole evening had been a trick of some sort to exact a contributary emotion
+ | ^~~~~~~~~~~~ `contributary` should probably be written as `con tributary`.
+ 530 | from me. I waited, and sure enough, in a moment she looked at me with an
+Suggest:
+ - Replace with: “con tributary”
+
+
+
Lint: Spelling (63 priority)
Message: |
551 | “Jordan’s going to play in the tournament tomorrow,” explained Daisy, “over at
@@ -749,9 +769,9 @@ Message: |
664 | it, you perceive, after a moment, the eyes of Doctor T. J. Eckleburg. The eyes
| ^~ Did you mean to spell `T.` this way?
Suggest:
- - Replace with: “T”
- Replace with: “Ta”
- Replace with: “Tb”
+ - Replace with: “Ti”
@@ -783,9 +803,9 @@ Message: |
665 | of Doctor T. J. Eckleburg are blue and gigantic—their retinas are one yard high.
| ^~ Did you mean to spell `T.` this way?
Suggest:
- - Replace with: “T”
- Replace with: “Ta”
- Replace with: “Tb”
+ - Replace with: “Ti”
@@ -902,9 +922,9 @@ Message: |
729 | spotted dress of dark blue crêpe-de-chine, contained no facet or gleam of
| ^~ Did you mean to spell `de` this way?
Suggest:
- - Replace with: “d”
- Replace with: “db”
- Replace with: “dc”
+ - Replace with: “dd”
@@ -949,8 +969,8 @@ Message: |
| ^~ Did you mean to spell `D.` this way?
Suggest:
- Replace with: “Do”
- - Replace with: “D”
- Replace with: “Db”
+ - Replace with: “Dc”
@@ -1323,6 +1343,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 1172 | York—every Monday these same oranges and lemons left his back door in a pyramid
+ 1173 | of pulpless halves. There was a machine in the kitchen which could extract the
+ | ^~~~~~~~ `pulpless` should probably be written as `pulp less`.
+Suggest:
+ - Replace with: “pulp less”
+
+
+
Lint: Spelling (63 priority)
Message: |
1179 | enormous garden. On buffet tables, garnished with glistening hors-d’œuvre,
@@ -1917,6 +1947,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 1693 | “Wha’s matter?” he inquired calmly. “Did we run outa gas?”
+ | ^~~~ `outa` should probably be written as `out a`.
+Suggest:
+ - Replace with: “out a”
+
+
+
Lint: Miscellaneous (31 priority)
Message: |
1701 | “It came off,” some one explained.
@@ -2451,9 +2490,9 @@ Message: |
1871 | afterward strangled his wife. Da Fontano the promoter came there, and Ed Legros
| ^~ Did you mean to spell `Da` this way?
Suggest:
- - Replace with: “D”
- Replace with: “Dad”
- Replace with: “Dam”
+ - Replace with: “Dc”
@@ -2720,8 +2759,8 @@ Message: |
| ^~ Did you mean to spell `L.` this way?
Suggest:
- Replace with: “L”
- - Replace with: “La”
- Replace with: “Lb”
+ - Replace with: “Lg”
@@ -2913,9 +2952,9 @@ Message: |
1982 | de Boulogne.
| ^~ Did you mean to spell `de` this way?
Suggest:
- - Replace with: “d”
- Replace with: “db”
- Replace with: “dc”
+ - Replace with: “dd”
@@ -2957,9 +2996,9 @@ Message: |
| ^~ Did you mean to spell `di` this way?
2007 | circular legend, “Montenegro, Nicolas Rex.”
Suggest:
- - Replace with: “d”
- Replace with: “db”
- Replace with: “dc”
+ - Replace with: “dd”
@@ -3443,6 +3482,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 2319 | That was nineteen-seventeen. By the next year I had a few beaux myself, and I
+ | ^~~~~ `beaux` should probably be written as `be aux`.
+ 2320 | began to play in tournaments, so I didn’t see Daisy very often. She went with a
+Suggest:
+ - Replace with: “be aux”
+
+
+
Lint: Spelling (63 priority)
Message: |
2329 | By the next autumn she was gay again, gay as ever. She had a début after the
@@ -3964,6 +4013,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 2866 | intensity. Now, in the reaction, he was running down like an overwound clock.
+ | ^~~~~~~~~ `overwound` should probably be written as `over wound`.
+Suggest:
+ - Replace with: “over wound”
+
+
+
Lint: Style (31 priority)
Message: |
2872 | “I’ve got a man in England who buys me clothes. He sends over a selection of
@@ -3998,6 +4056,17 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 2878 | brought more and the soft rich heap mounted higher—shirts with stripes and
+ 2879 | scrolls and plaids in coral and applegreen and lavender and faint orange, with
+ | ^~~~~~~~~~ `applegreen` should probably be written as `apple green`.
+ 2880 | monograms of Indian blue. Suddenly, with a strained sound, Daisy bent her head
+Suggest:
+ - Replace with: “apple green”
+
+
+
Lint: Readability (127 priority)
Message: |
2887 | After the house, we were to see the grounds and the swimming-pool, and the
@@ -4109,8 +4178,8 @@ Message: |
3024 | a source of satisfaction to James Gatz of North Dakota, isn’t easy to say.
| ^~~~ Did you mean to spell `Gatz` this way?
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -4120,8 +4189,8 @@ Message: |
3026 | James Gatz—that was really, or at least legally, his name. He had changed it at
| ^~~~ Did you mean to spell `Gatz` this way?
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -4144,8 +4213,8 @@ Message: |
3029 | on Lake Superior. It was James Gatz who had been loafing along the beach that
| ^~~~ Did you mean to spell `Gatz` this way?
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -4188,9 +4257,9 @@ Message: |
| ^~ Did you mean to spell `de` this way?
3075 | sent him to sea in a yacht, were common property of the turgid journalism
Suggest:
- - Replace with: “d”
- Replace with: “db”
- Replace with: “dc”
+ - Replace with: “dd”
@@ -4223,8 +4292,8 @@ Message: |
3079 | To young Gatz, resting on his oars and looking up at the railed deck, that yacht
| ^~~~ Did you mean to spell `Gatz` this way?
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -4264,6 +4333,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 3089 | in turn steward, mate, skipper, secretary, and even jailor, for Dan Cody sober
+ | ^~~~~~ `jailor` should probably be written as `jail or`.
+ 3090 | knew what lavish doings Dan Cody drunk might soon be about, and he provided for
+Suggest:
+ - Replace with: “jail or”
+
+
+
Lint: Readability (127 priority)
Message: |
3096 | I remember the portrait of him up in Gatsby’s bedroom, a gray, florid man with a
@@ -4455,6 +4534,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 3349 | But the rest offended her—and inarguably, because it wasn’t a gesture but an
+ | ^~~~~~~~~~ `inarguably` should probably be written as `in arguably`.
+Suggest:
+ - Replace with: “in arguably”
+
+
+
Lint: Readability (127 priority)
Message: |
3350 | emotion. She was appalled by West Egg, this unprecedented “place” that Broadway
@@ -4812,9 +4900,9 @@ Message: |
3647 | up now, and say—How-de-do.”
| ^~ Did you mean to spell `de` this way?
Suggest:
- - Replace with: “d”
- Replace with: “db”
- Replace with: “dc”
+ - Replace with: “dd”
@@ -4934,9 +5022,9 @@ Message: |
3874 | while in silence. Then as Doctor T. J. Eckleburg’s faded eyes came into sight
| ^~ Did you mean to spell `T.` this way?
Suggest:
- - Replace with: “T”
- Replace with: “Ta”
- Replace with: “Tb”
+ - Replace with: “Ti”
@@ -5003,9 +5091,9 @@ Message: |
3948 | behind. Over the ashheaps the giant eyes of Doctor T. J. Eckleburg kept their
| ^~ Did you mean to spell `T.` this way?
Suggest:
- - Replace with: “T”
- Replace with: “Ta”
- Replace with: “Tb”
+ - Replace with: “Ti”
@@ -5209,8 +5297,17 @@ Message: |
| ^~ Did you mean to spell `lf` this way?
Suggest:
- Replace with: “l”
- - Replace with: “la”
- Replace with: “lb”
+ - Replace with: “lg”
+
+
+
+Lint: Typo (31 priority)
+Message: |
+ 4073 | “We're getting old,” said Daisy. “lf we were young we’d rise and dance.”
+ | ^~ `lf` should probably be written as `l f`.
+Suggest:
+ - Replace with: “l f”
@@ -5651,9 +5748,9 @@ Message: |
4479 | “Oh, my Ga-od! Oh, my Ga-od! Oh, Ga-od! Oh, my Ga-od!”
| ^~ Did you mean to spell `od` this way?
Suggest:
- - Replace with: “ob”
- Replace with: “odd”
- Replace with: “ode”
+ - Replace with: “of”
@@ -5662,9 +5759,9 @@ Message: |
4479 | “Oh, my Ga-od! Oh, my Ga-od! Oh, Ga-od! Oh, my Ga-od!”
| ^~ Did you mean to spell `od` this way?
Suggest:
- - Replace with: “ob”
- Replace with: “odd”
- Replace with: “ode”
+ - Replace with: “of”
@@ -5673,9 +5770,9 @@ Message: |
4479 | “Oh, my Ga-od! Oh, my Ga-od! Oh, Ga-od! Oh, my Ga-od!”
| ^~ Did you mean to spell `od` this way?
Suggest:
- - Replace with: “ob”
- Replace with: “odd”
- Replace with: “ode”
+ - Replace with: “of”
@@ -5684,9 +5781,9 @@ Message: |
4479 | “Oh, my Ga-od! Oh, my Ga-od! Oh, Ga-od! Oh, my Ga-od!”
| ^~ Did you mean to spell `od` this way?
Suggest:
- - Replace with: “ob”
- Replace with: “odd”
- Replace with: “ode”
+ - Replace with: “of”
@@ -5695,9 +5792,9 @@ Message: |
4484 | “M-a-v—” the policeman was saying, “—o———”
| ^ Did you mean to spell `o` this way?
Suggest:
- - Replace with: “ob”
- Replace with: “of”
- Replace with: “oh”
+ - Replace with: “oi”
@@ -5706,9 +5803,9 @@ Message: |
4486 | “No, r—” corrected the man, “M-a-v-r-o———”
| ^ Did you mean to spell `o` this way?
Suggest:
- - Replace with: “ob”
- Replace with: “of”
- Replace with: “oh”
+ - Replace with: “oi”
@@ -5717,9 +5814,9 @@ Message: |
4490 | “r—” said the policeman, “o———”
| ^ Did you mean to spell `o` this way?
Suggest:
- - Replace with: “ob”
- Replace with: “of”
- Replace with: “oh”
+ - Replace with: “oi”
@@ -5754,6 +5851,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 4503 | “She ran out ina road. Son-of-a-bitch didn’t even stopus car.”
+ | ^~~~~~ `stopus` should probably be written as `st opus`.
+Suggest:
+ - Replace with: “st opus”
+
+
+
Lint: Spelling (63 priority)
Message: |
4505 | “There was two cars,” said Michaelis, “one comin’, one goin’, see?”
@@ -5774,6 +5880,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 4505 | “There was two cars,” said Michaelis, “one comin’, one goin’, see?”
+ | ^~~~~ `comin` should probably be written as `co min`.
+Suggest:
+ - Replace with: “co min”
+
+
+
Lint: Spelling (63 priority)
Message: |
4505 | “There was two cars,” said Michaelis, “one comin’, one goin’, see?”
@@ -5785,6 +5900,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 4505 | “There was two cars,” said Michaelis, “one comin’, one goin’, see?”
+ | ^~~~ `goin` should probably be written as `go in`.
+Suggest:
+ - Replace with: “go in”
+
+
+
Lint: Spelling (63 priority)
Message: |
4509 | “One goin’ each way. Well, she”—his hand rose toward the blankets but stopped
@@ -5796,6 +5920,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 4509 | “One goin’ each way. Well, she”—his hand rose toward the blankets but stopped
+ | ^~~~ `goin` should probably be written as `go in`.
+Suggest:
+ - Replace with: “go in”
+
+
+
Lint: Formatting (255 priority)
Message: |
4509 | “One goin’ each way. Well, she”—his hand rose toward the blankets but stopped
@@ -5826,6 +5959,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 4510 | half way and fell to his side—“she ran out there an’ the one comin’ from N’York
+ | ^~~~~ `comin` should probably be written as `co min`.
+ 4511 | knock right into her, goin’ thirty or forty miles an hour.”
+Suggest:
+ - Replace with: “co min”
+
+
+
Lint: Spelling (63 priority)
Message: |
4510 | half way and fell to his side—“she ran out there an’ the one comin’ from N’York
@@ -5850,6 +5993,16 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 4510 | half way and fell to his side—“she ran out there an’ the one comin’ from N’York
+ 4511 | knock right into her, goin’ thirty or forty miles an hour.”
+ | ^~~~ `goin` should probably be written as `go in`.
+Suggest:
+ - Replace with: “go in”
+
+
+
Lint: Formatting (255 priority)
Message: |
4511 | knock right into her, goin’ thirty or forty miles an hour.”
@@ -6366,9 +6519,9 @@ Message: |
5156 | of Doctor T. J. Eckleburg, which had just emerged, pale and enormous, from the
| ^~ Did you mean to spell `T.` this way?
Suggest:
- - Replace with: “T”
- Replace with: “Ta”
- Replace with: “Tb”
+ - Replace with: “Ti”
@@ -6756,7 +6909,7 @@ Message: |
Suggest:
- Replace with: “Cu”
- Replace with: “C”
- - Replace with: “Ca”
+ - Replace with: “Cc”
@@ -6766,8 +6919,8 @@ Message: |
| ^~~~ Did you mean to spell `Gatz` this way?
5353 | from a town in Minnesota. It said only that the sender was leaving immediately
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -6797,8 +6950,8 @@ Message: |
5385 | After a little while Mr. Gatz opened the door and came out, his mouth ajar, his
| ^~~~ Did you mean to spell `Gatz` this way?
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -6832,8 +6985,8 @@ Message: |
5396 | “Gatz is my name.”
| ^~~~ Did you mean to spell `Gatz` this way?
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -6843,8 +6996,8 @@ Message: |
5398 | “—Mr. Gatz. I thought you might want to take the body West.”
| ^~~~ Did you mean to spell `Gatz` this way?
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -7041,8 +7194,8 @@ Message: |
| ^~~~ Did you mean to spell `Gatz` this way?
5560 | up and down excitedly in the hall. His pride in his son and in his son’s
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -7128,8 +7281,8 @@ Message: |
5629 | then Mr. Gatz and the minister and I in the limousine, and a little later four
| ^~~~ Did you mean to spell `Gatz` this way?
Suggest:
- - Replace with: “Gate”
- Replace with: “Ga's”
+ - Replace with: “Gate”
- Replace with: “GHz”
@@ -7418,6 +7571,15 @@ Suggest:
+Lint: Typo (31 priority)
+Message: |
+ 5714 | leaf, her face the same brown tint as the fingerless glove on her knee. When I
+ | ^~~~~~~~~~ `fingerless` should probably be written as `finger less`.
+Suggest:
+ - Replace with: “finger less”
+
+
+
Lint: Punctuation (31 priority)
Message: |
5721 | “Nevertheless you did throw me over,” said Jordan suddenly. ‘‘You threw me over