修复代码警告
This commit is contained in:
@@ -102,7 +102,7 @@ def parse_department(string):
|
|||||||
result = []
|
result = []
|
||||||
if not string:
|
if not string:
|
||||||
return result
|
return result
|
||||||
string = re.sub(r'\([^()]*\)|\[[^\[\]]*\]|\{[^\{\}]*\}|([^()]*)|[^⺀-鿿]', '', string)[:255]
|
string = re.sub(r'\([^()]*\)|\[[^\[\]]*]|\{[^{}]*}|([^()]*)|[^⺀-鿿]', '', string)[:255]
|
||||||
if string == "科":
|
if string == "科":
|
||||||
return result
|
return result
|
||||||
result.append(string)
|
result.append(string)
|
||||||
|
|||||||
12
util/util.py
12
util/util.py
@@ -131,7 +131,7 @@ def chinese_to_number(chinese):
|
|||||||
num = chinese_char_to_number(c)
|
num = chinese_char_to_number(c)
|
||||||
if num >= 0:
|
if num >= 0:
|
||||||
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)
|
section += number * (unit[0] / 10)
|
||||||
unit = [None, False]
|
unit = [None, False]
|
||||||
elif number > 0:
|
elif number > 0:
|
||||||
@@ -139,21 +139,21 @@ def chinese_to_number(chinese):
|
|||||||
number = num
|
number = num
|
||||||
else:
|
else:
|
||||||
unit = chinese_to_money_unit(c)
|
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}")
|
raise ValueError(f"{chinese} has unknown unit '{c}' at: {i}")
|
||||||
if unit[1]:
|
if unit[1]:
|
||||||
section = (section + number) * unit[0]
|
section = (section + number) * unit[0]
|
||||||
result += section
|
result += section
|
||||||
section = 0
|
section = 0
|
||||||
else:
|
else:
|
||||||
unitNumber = number
|
unit_number = number
|
||||||
if number == 0 and i == 0:
|
if number == 0 and i == 0:
|
||||||
unitNumber = 1
|
unit_number = 1
|
||||||
|
|
||||||
section += unitNumber * unit[0]
|
section += unit_number * unit[0]
|
||||||
number = 0
|
number = 0
|
||||||
|
|
||||||
if number > 0 and unit[0] != None:
|
if number > 0 and unit[0] is not None:
|
||||||
number *= unit[0] / 10
|
number *= unit[0] / 10
|
||||||
return result + section + number
|
return result + section + number
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ def visual_model_test(model_type, test_img, task_path, schema):
|
|||||||
imgs = image_util.split(test_img)
|
imgs = image_util.split(test_img)
|
||||||
layout = []
|
layout = []
|
||||||
temp_files_paths = []
|
temp_files_paths = []
|
||||||
doc_parser = DocParser(layout_analysis=False)
|
# doc_parser = DocParser(layout_analysis=False)
|
||||||
for img in imgs:
|
for img in imgs:
|
||||||
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
|
with tempfile.NamedTemporaryFile(delete=False, suffix=".jpg") as temp_file:
|
||||||
# angle = image_util.parse_rotation_angles(img["img"])[0]
|
# angle = image_util.parse_rotation_angles(img["img"])[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user