修复代码警告

This commit is contained in:
2024-07-23 17:27:09 +08:00
parent d2ea9ec521
commit 72e23e3132
3 changed files with 8 additions and 8 deletions

View File

@@ -102,7 +102,7 @@ def parse_department(string):
result = []
if not string:
return result
string = re.sub(r'\([^()]*\)|\[[^\[\]]*\]|\{[^\{\}]*\}|[^]*|[^⺀-鿿]', '', string)[:255]
string = re.sub(r'\([^()]*\)|\[[^\[\]]*]|\{[^{}]*}|[^]*|[^⺀-鿿]', '', string)[:255]
if string == "":
return result
result.append(string)

View File

@@ -131,7 +131,7 @@ def chinese_to_number(chinese):
num = chinese_char_to_number(c)
if num >= 0:
if num == 0:
if number > 0 and unit[0] != None:
if number > 0 and unit[0] is not None:
section += number * (unit[0] / 10)
unit = [None, False]
elif number > 0:
@@ -139,21 +139,21 @@ def chinese_to_number(chinese):
number = num
else:
unit = chinese_to_money_unit(c)
if unit[0] == None:
if unit[0] is None:
raise ValueError(f"{chinese} has unknown unit '{c}' at: {i}")
if unit[1]:
section = (section + number) * unit[0]
result += section
section = 0
else:
unitNumber = number
unit_number = number
if number == 0 and i == 0:
unitNumber = 1
unit_number = 1
section += unitNumber * unit[0]
section += unit_number * unit[0]
number = 0
if number > 0 and unit[0] != None:
if number > 0 and unit[0] is not None:
number *= unit[0] / 10
return result + section + number

View File

@@ -50,7 +50,7 @@ def visual_model_test(model_type, test_img, task_path, schema):
imgs = image_util.split(test_img)
layout = []
temp_files_paths = []
doc_parser = DocParser(layout_analysis=False)
# doc_parser = DocParser(layout_analysis=False)
for img in imgs:
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
# angle = image_util.parse_rotation_angles(img["img"])[0]