Skip to content

Commit

Permalink
suggester: Handle init & all casings
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Sep 26, 2024
1 parent 2cf7312 commit e3ba709
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/suggester.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,25 @@ impl<'a, S: BuildHasher> Suggester<'a, S> {
}
hq_suggestions |= self.suggest_low(&word, out);
}
_ => todo!(),
Casing::Init => {
hq_suggestions |= self.suggest_low(&word, out);
let word = self.checker.aff.options.case_handling.lowercase(&word);
hq_suggestions |= self.suggest_low(&word, out);
}
Casing::All => {
let lower = self.checker.aff.options.case_handling.lowercase(&word);
if self.checker.aff.options.keep_case_flag.is_some() && self.checker.check(&lower) {
out.insert(0, lower.clone());
}
hq_suggestions |= self.suggest_low(&lower, out);
let title = self.checker.aff.options.case_handling.titlecase(&lower);
hq_suggestions |= self.suggest_low(&title, out);
for suggestion in out.iter_mut() {
let upper = self.checker.aff.options.case_handling.uppercase(suggestion);
*suggestion = upper;
}
}
Casing::Camel | Casing::Pascal => todo!(),
}

if !hq_suggestions && self.checker.aff.options.max_ngram_suggestions != 0 {
Expand Down

0 comments on commit e3ba709

Please sign in to comment.