mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-24 10:27:44 -06:00
Improve Polish spelling suggestions for final consonant devoicing (#1298)
Co-authored-by: neronek22 <aantoszek@gmail.com>
This commit is contained in:
@@ -275,7 +275,10 @@ pub fn suggest_in(d: &AffixDict, word: &str, max: usize) -> Vec<String> {
|
||||
if let Some(x) = v.get_mut(i) {
|
||||
*x = c;
|
||||
}
|
||||
col.offer(&s(&v), COST_MISTYPE);
|
||||
// Final devoicing can make a voiced consonant sound voiceless.
|
||||
let final_devoicing = i == n - 1 && matches!((chars[i], c), ('p', 'b') | ('t', 'd') | ('k', 'g'));
|
||||
let cost = if final_devoicing { COST_ADD_DIACRITIC - 1 } else { COST_MISTYPE };
|
||||
col.offer(&s(&v), cost);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,6 +392,13 @@ mod tests {
|
||||
has("dziewczyan", "dziewczyna");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn voiced_consonant_suggestion_ranks_first() {
|
||||
crate::pl::test_dict::install();
|
||||
let result = suggest("chlep", 6);
|
||||
assert_eq!(result.first().map(String::as_str), Some("chleb"), "{result:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_likeliest_fix_comes_first() {
|
||||
crate::pl::test_dict::install();
|
||||
|
||||
@@ -33,10 +33,16 @@ PFX N 0 nie .
|
||||
";
|
||||
|
||||
/// Stems (the count line first, as in Hunspell files).
|
||||
pub const DIC: &str = "63
|
||||
pub const DIC: &str = "69
|
||||
źdźbło
|
||||
gżegżółka
|
||||
chrząszcz
|
||||
chleb
|
||||
chłep
|
||||
chlap
|
||||
chlip
|
||||
chlup
|
||||
chlej
|
||||
pięćdziesięciu
|
||||
rzeka
|
||||
którzy
|
||||
|
||||
Reference in New Issue
Block a user