def get_CUL_score(record_elems, resp_elems):
if record_elems is None or resp_elems is None:
return None
elif isinstance(record_elems, str) and isinstance(resp_elems, str):
score = str(fuzz.token_sort_ratio(record_elems, resp_elems))
return score
elif isinstance(record_elems, str) and not isinstance(resp_elems, str):
scores = []
for n in range(len(resp_elems)):
score = str(fuzz.token_sort_ratio(record_elems, resp_elems[n]))
scores.append(score)
return max(scores)
elif not isinstance(record_elems, str) and isinstance(resp_elems, str):
scores = []
for n in range(len(record_elems)):
score = str(fuzz.token_sort_ratio(record_elems[n], resp_elems))
scores.append(score)
return max(scores)
elif not isinstance(record_elems, str) and not isinstance(resp_elems, str):
scores = []
for n in range(len(record_elems)):
for m in range(len(resp_elems)):
score = str(fuzz.token_sort_ratio(record_elems[n],
resp_elems[m]))
scores.append(score)
if scores != []:
return max(scores)
else:
return None
评论列表
文章目录