fix(katana): add another workaround

This commit is contained in:
tretrauit 2024-01-05 22:07:04 +07:00
parent 0ada9f6e46
commit f15b07c68b
2 changed files with 17 additions and 0 deletions

View File

@ -16,6 +16,12 @@ static TESSERACT: LazyLock<Arc<Mutex<LepTess>>> = LazyLock::new(|| {
static mut TESSERACT_VEC: Vec<Arc<Mutex<LepTess>>> = Vec::new(); static mut TESSERACT_VEC: Vec<Arc<Mutex<LepTess>>> = 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<Mutex<LepTess>> { pub fn get_tesseract(numeric_only: bool) -> Arc<Mutex<LepTess>> {
TESSERACT.clone() TESSERACT.clone()
} }

View File

@ -57,6 +57,14 @@ fn fix_tesseract_string(text: &mut String) {
// This is usually the corner of the card // This is usually the corner of the card
trace!("Text: {}", text); trace!("Text: {}", text);
replace_string(text, "A\n", ""); 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) // Workaround for "\n." (and others in the future)
for (i, c) in text.clone().chars().enumerate() { for (i, c) in text.clone().chars().enumerate() {
if c != '\n' { if c != '\n' {
@ -113,6 +121,9 @@ fn fix_tesseract_string(text: &mut String) {
// Fix "1ll" -> "III" // Fix "1ll" -> "III"
trace!("Text: {}", text); trace!("Text: {}", text);
replace_string(text, "1ll", "III"); replace_string(text, "1ll", "III");
// Fix "lll" -> "!!!"
trace!("Text: {}", text);
replace_string(text, "lll", "!!!");
// Replace multiple spaces with one space // Replace multiple spaces with one space
trace!("Text: {}", text); trace!("Text: {}", text);
while replace_string(text, " ", " ") { while replace_string(text, " ", " ") {