Fix: Handle OCR error on bleesings

This commit is contained in:
LmeSzinc 2023-09-11 00:38:32 +08:00
parent 5988590b05
commit 269f704abd
3 changed files with 11 additions and 7 deletions

View File

@ -6,7 +6,7 @@ from typing import ClassVar
import module.config.server as server import module.config.server as server
from module.exception import ScriptError from module.exception import ScriptError
REGEX_PUNCTUATION = re.compile(r'[ ,.\'"“”,。:!??·•\-—/\\\n\t()\[\]()「」『』【】《》]') REGEX_PUNCTUATION = re.compile(r'[ ,.\'"“”,。:!??·•\-—/\\\n\t()\[\]()「」『』【】《》]')
def parse_name(n): def parse_name(n):

View File

@ -61,18 +61,18 @@ class RogueBuffOcr(Ocr):
def after_process(self, result): def after_process(self, result):
result = super().after_process(result) result = super().after_process(result)
if self.lang == 'ch': if self.lang == 'cn':
replace_pattern_dict = { replace_pattern_dict = {
"蓬失": "蓬矢", "蓬失": "蓬矢",
"柘弓危失": "柘弓危矢", "柘弓危失": "柘弓危矢",
"飞虹珠?凿?齿": "飞虹诛凿齿", "飞虹珠?凿?齿": "飞虹诛凿齿",
"培步危": "天棓步危", "[梧]步危": "天棓步危",
"云[摘销锅]?逐步离": "云镝逐步离", "云[摘销锅]?逐步离": "云镝逐步离",
"制桑": "制穹桑", "制桑": "制穹桑",
"乌号基": "乌号綦", "乌号基": "乌号綦",
"追摩物": "追孽物", "追摩物": "追孽物",
"特月": "狩月", "特月": "狩月",
"彤弓素增?": "彤弓素矰", "彤弓素.*": "彤弓素矰",
"白决射御": "白矢决射御", "白决射御": "白矢决射御",
"苦表": "苦衷", "苦表": "苦衷",
"[沦沧]肌髓": "沦浃肌髓", "[沦沧]肌髓": "沦浃肌髓",
@ -260,7 +260,10 @@ class RogueBlessingSelector(RogueSelector):
return True return True
def load_filter(self): def load_filter(self):
keyword = self.ocr_results[0].matched_keyword try:
keyword = self.ocr_results[0].matched_keyword
except IndexError:
return
if not isinstance(keyword, (RogueBlessing, RogueResonance)): if not isinstance(keyword, (RogueBlessing, RogueResonance)):
return return
filter_configs = { filter_configs = {

View File

@ -16,10 +16,10 @@ from tasks.rogue.utils import get_regex_from_keyword_name, parse_name
CURIO_FILTER_ATTR = tuple() CURIO_FILTER_ATTR = tuple()
CURIO_ATTR_NAME = 'curio_name' CURIO_ATTR_NAME = 'curio_name'
pattern = get_regex_from_keyword_name(RogueCurio, CURIO_ATTR_NAME) patt = get_regex_from_keyword_name(RogueCurio, CURIO_ATTR_NAME)
CURIO_FILTER_ATTR += (CURIO_ATTR_NAME,) CURIO_FILTER_ATTR += (CURIO_ATTR_NAME,)
CURIO_FILTER_PRESET = ('random', 'unrecorded') CURIO_FILTER_PRESET = ('random', 'unrecorded')
FILTER_REGEX = re.compile(pattern) FILTER_REGEX = re.compile(patt)
CURIO_FILTER = MultiLangFilter(FILTER_REGEX, CURIO_FILTER_ATTR, CURIO_FILTER_PRESET) CURIO_FILTER = MultiLangFilter(FILTER_REGEX, CURIO_FILTER_ATTR, CURIO_FILTER_PRESET)
@ -32,6 +32,7 @@ class RogueCurioOcr(Ocr):
replace_pattern_dict = { replace_pattern_dict = {
"": "", "": "",
"漂灭": "湮灭", "漂灭": "湮灭",
"殷子": "骰子",
} }
for pattern, replace in replace_pattern_dict.items(): for pattern, replace in replace_pattern_dict.items():
result = re.sub(pattern, replace, result) result = re.sub(pattern, replace, result)