From 04142e3ca85d5fd87c7b1a268d36ab380bca4888 Mon Sep 17 00:00:00 2001 From: ZeyuTeng96 <96521059+ZeyuTeng96@users.noreply.github.com> Date: Fri, 12 Jan 2024 23:07:46 +0800 Subject: [PATCH] [faq] fix bug of evaluate.py (#7840) --- .../supervised_qa/faq_finance/evaluate.py | 10 +++++----- .../supervised_qa/faq_system/evaluate.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/applications/question_answering/supervised_qa/faq_finance/evaluate.py b/applications/question_answering/supervised_qa/faq_finance/evaluate.py index aabeadf5b197..390155922dc1 100644 --- a/applications/question_answering/supervised_qa/faq_finance/evaluate.py +++ b/applications/question_answering/supervised_qa/faq_finance/evaluate.py @@ -59,16 +59,16 @@ def recall(rs, N=10): with open(args.recall_result_file, "r", encoding="utf-8") as f: relevance_labels = [] for index, line in enumerate(f): - - if index % args.recall_num == 0 and index != 0: - rs.append(relevance_labels) - relevance_labels = [] - text, recalled_text, cosine_sim = line.rstrip().split("\t") if text2similar[text] == recalled_text: relevance_labels.append(1) else: relevance_labels.append(0) + + if (index + 1) % args.recall_num == 0: + rs.append(relevance_labels) + relevance_labels = [] + recall_N = [] recall_num = [1, 5, 10] result = open("result.tsv", "a") diff --git a/applications/question_answering/supervised_qa/faq_system/evaluate.py b/applications/question_answering/supervised_qa/faq_system/evaluate.py index aabeadf5b197..390155922dc1 100644 --- a/applications/question_answering/supervised_qa/faq_system/evaluate.py +++ b/applications/question_answering/supervised_qa/faq_system/evaluate.py @@ -59,16 +59,16 @@ def recall(rs, N=10): with open(args.recall_result_file, "r", encoding="utf-8") as f: relevance_labels = [] for index, line in enumerate(f): - - if index % args.recall_num == 0 and index != 0: - rs.append(relevance_labels) - relevance_labels = [] - text, recalled_text, cosine_sim = line.rstrip().split("\t") if text2similar[text] == recalled_text: relevance_labels.append(1) else: relevance_labels.append(0) + + if (index + 1) % args.recall_num == 0: + rs.append(relevance_labels) + relevance_labels = [] + recall_N = [] recall_num = [1, 5, 10] result = open("result.tsv", "a")