From f15b07c68b2330cdd79649fe77f91149f3f8f506 Mon Sep 17 00:00:00 2001 From: tretrauit Date: Fri, 5 Jan 2024 22:07:04 +0700 Subject: [PATCH] fix(katana): add another workaround --- swordfish-common/src/tesseract/libtesseract.rs | 6 ++++++ swordfish/src/katana.rs | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/swordfish-common/src/tesseract/libtesseract.rs b/swordfish-common/src/tesseract/libtesseract.rs index f1aa3e0..91774c5 100644 --- a/swordfish-common/src/tesseract/libtesseract.rs +++ b/swordfish-common/src/tesseract/libtesseract.rs @@ -16,6 +16,12 @@ static TESSERACT: LazyLock>> = LazyLock::new(|| { static mut TESSERACT_VEC: Vec>> = Vec::new(); +/// +/// Get a Tesseract instance. +/// +/// Deprecated because it provides no performance benefit, if you really need +/// then use get_tesseract_from_vec. +/// pub fn get_tesseract(numeric_only: bool) -> Arc> { TESSERACT.clone() } diff --git a/swordfish/src/katana.rs b/swordfish/src/katana.rs index 778229d..3994434 100644 --- a/swordfish/src/katana.rs +++ b/swordfish/src/katana.rs @@ -57,6 +57,14 @@ fn fix_tesseract_string(text: &mut String) { // This is usually the corner of the card trace!("Text: {}", text); replace_string(text, "A\n", ""); + // Workaround for '“NO' + // This is usually the left bottom corner of the card + trace!("Text: {}", text); + if text.ends_with(r##"“NO"##) { + for _ in 0..3 { + text.pop(); + } + } // Workaround for "\n." (and others in the future) for (i, c) in text.clone().chars().enumerate() { if c != '\n' { @@ -113,6 +121,9 @@ fn fix_tesseract_string(text: &mut String) { // Fix "1ll" -> "III" trace!("Text: {}", text); replace_string(text, "1ll", "III"); + // Fix "lll" -> "!!!" + trace!("Text: {}", text); + replace_string(text, "lll", "!!!"); // Replace multiple spaces with one space trace!("Text: {}", text); while replace_string(text, " ", " ") {