Skip to content

Commit

Permalink
[faq] fix bug of evaluate.py (#7840)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeyuTeng96 authored Jan 12, 2024
1 parent 2a5dba9 commit 04142e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 04142e3

Please sign in to comment.