added error handling
This commit is contained in:
parent
02244e4e91
commit
c250180ef7
|
|
@ -1,7 +1,10 @@
|
||||||
import re
|
import re
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
import math
|
||||||
from AgentProxy import AgentProxy
|
from AgentProxy import AgentProxy
|
||||||
|
|
||||||
|
def is_none_or_nan(variable):
|
||||||
|
return variable is None or (isinstance(variable, (int, float)) and math.isnan(variable))
|
||||||
|
|
||||||
result_category_list = [
|
result_category_list = [
|
||||||
"完成需求确认与收集",
|
"完成需求确认与收集",
|
||||||
|
|
@ -22,7 +25,10 @@ data = []
|
||||||
|
|
||||||
for index, row in df.iterrows():
|
for index, row in df.iterrows():
|
||||||
text = row["行动结果"]
|
text = row["行动结果"]
|
||||||
# print(text)
|
if is_none_or_nan(text):
|
||||||
|
print(f"index{index} ")
|
||||||
|
continue
|
||||||
|
|
||||||
action_pattern = re.compile(r'\*\*销售动作\*\*:(.+?)\n')
|
action_pattern = re.compile(r'\*\*销售动作\*\*:(.+?)\n')
|
||||||
category_pattern = re.compile(r'\*\*销售动作归类\*\*:(.+?)\n')
|
category_pattern = re.compile(r'\*\*销售动作归类\*\*:(.+?)\n')
|
||||||
result_pattern = re.compile(r'\*\*销售动作行动结果\*\*:(.+?)\n')
|
result_pattern = re.compile(r'\*\*销售动作行动结果\*\*:(.+?)\n')
|
||||||
|
|
@ -33,9 +39,9 @@ for index, row in df.iterrows():
|
||||||
results = result_pattern.findall(text)
|
results = result_pattern.findall(text)
|
||||||
abstract_results = abstract_result_pattern.findall(text)
|
abstract_results = abstract_result_pattern.findall(text)
|
||||||
if (len(actions) == len(categories) and len(actions) == len(results) and len(actions) == len(abstract_results)):
|
if (len(actions) == len(categories) and len(actions) == len(results) and len(actions) == len(abstract_results)):
|
||||||
print("index result compliance: true")
|
print(f"index{index} result compliance: true")
|
||||||
else:
|
else:
|
||||||
print("index result compliance: false")
|
print(f"index{index} result compliance: false")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Combine into a list of dictionaries
|
# Combine into a list of dictionaries
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue