Skip to content

Commit

Permalink
use grapheme clusters instead of chars
Browse files Browse the repository at this point in the history
fixes #35 may break something else
  • Loading branch information
flammie committed Nov 1, 2024
1 parent d7fdc1b commit cb27a91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion divvunspell/src/speller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ use hashbrown::HashMap;
use serde::{Deserialize, Serialize};
use smol_str::SmolStr;
use unic_ucd_category::GeneralCategory;
use unic_segment::Graphemes;

use self::worker::SpellerWorker;
use crate::speller::suggestion::Suggestion;
use crate::tokenizer::case_handling::CaseHandler;
use crate::transducer::Transducer;
use crate::types::{SymbolNumber, Weight};


pub mod suggestion;
mod worker;

Expand Down Expand Up @@ -172,7 +174,8 @@ where
let alphabet = self.mutator().alphabet();
let key_table = alphabet.key_table();

word.chars()
log::trace!("to_input_vec: {}", word);
Graphemes::new(word)
.map(|ch| {
let s = ch.to_string();
key_table
Expand Down
2 changes: 1 addition & 1 deletion divvunspell/src/speller/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ where

let input_sym = alphabet_translator[self.input[input_state as usize] as usize];
let next_lexicon_state = next_node.lexicon_state + 1;
log::trace!("lexicon consuming {}?",
log::trace!("lexicon consuming {}: {}", input_sym,
self.speller.lexicon.alphabet().string_from_symbols(&[input_sym]));

if !lexicon.has_transitions(next_lexicon_state, Some(input_sym)) {
Expand Down

1 comment on commit cb27a91

@trondtynnol
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Takk!

Please sign in to comment.