From 07bf9d9947e4262c10aa0b41b23bf969bf55df4e Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Sat, 28 Feb 2026 03:42:17 +0800 Subject: [PATCH] Fix: Handle wrong OCR error like "I4-4" (#5532) --- module/campaign/campaign_ocr.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/module/campaign/campaign_ocr.py b/module/campaign/campaign_ocr.py index 9dc04193e..f39a29ae8 100644 --- a/module/campaign/campaign_ocr.py +++ b/module/campaign/campaign_ocr.py @@ -41,11 +41,21 @@ class CampaignOcr(ModuleBase): @staticmethod def _campaign_ocr_result_process(result): # The result will be like '7--2', because tha dash in game is '–' not '-' - result = result.lower().replace('--', '-').replace('--', '-') - if result.startswith('-'): - result = result[1:] + result = result.replace('--', '-').replace('--', '-').lstrip('-') + + # Replace wrong 'I' from results like 'I1-1', '1I-1', 'I-I', '11-I', 'I4-4', to '1' + # while keeping results like 'isp-2', 'sp1' + def replace_func(match): + segment = match.group(0) + return segment.replace('I', '1') + + result = re.sub(r'[0-9I]+-[0-9I]+', replace_func, result, count=1) + + # Convert '72' to '7-2' if len(result) == 2 and result[0].isdigit(): result = '-'.join(result) + + result = result.lower() return result @staticmethod