From 5d614df9f9dd62d21a507fa6ec76f34fe7a01a78 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Wed, 10 Jan 2024 06:16:10 +0700 Subject: [PATCH] fix(katana): fix broken text algorithm --- swordfish/src/katana.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/swordfish/src/katana.rs b/swordfish/src/katana.rs index 4f3e0c7..f516544 100644 --- a/swordfish/src/katana.rs +++ b/swordfish/src/katana.rs @@ -159,12 +159,13 @@ fn fix_tesseract_string(text: &mut String) { trace!("Text: {}", text); let mut leading_spaces = 0; let mut ending_spaces = 0; - while text.starts_with(|c: char| c.is_whitespace()) { + let mut text_chars = text.chars(); + while text_chars.nth(0).unwrap().is_whitespace() { trace!("Removing leading space"); leading_spaces += 1; } // Workaround if the last character is a space - while text.ends_with(|c: char| c.is_whitespace()) { + while text_chars.nth_back(0).unwrap().is_whitespace() { trace!("Removing ending space"); ending_spaces += 1; }