Skip to content
Snippets Groups Projects
Commit fdf00601 authored by Hsien-Chin Lin's avatar Hsien-Chin Lin
Browse files

wip

parent 55753fb9
No related branches found
No related tags found
No related merge requests found
......@@ -22,22 +22,23 @@ def get_sent(candidates):
else:
return [x["gen_utts"] for x in candidates["dialog"]]
def SelfBLEU(sentences):
metric = load_metric("sacrebleu")
result = []
for i, sent in tqdm(enumerate(sentences), ascii=True):
r = metric.compute(predictions=[sent], references=[sentences[i:]+sentences[i+1:]])
r = metric.compute(predictions=[sent], references=[
sentences[i:]+sentences[i+1:]])
result.append(r["score"])
return sum(result)/len(result)
def calculate(candidates):
sentences = get_sent(candidates)
bleu = SelfBLEU(sentences)
x = bleu.get_score()
print(x)
# x = bleu.get_score()
print(bleu)
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment