Skip to content
Snippets Groups Projects
Commit c0e80d5a authored by zz-jacob's avatar zz-jacob
Browse files

use sacrebleu.corpus_bleu()

parent 6e49bf10
No related branches found
No related tags found
No related merge requests found
import sys
from nltk.translate.bleu_score import corpus_bleu
import sacrebleu
from nltk.tokenize import word_tokenize
sys.path.append('../..')
import json
......@@ -32,9 +33,10 @@ def evaluate(predict_result, ontology):
references = []
candidates = []
for i in range(len(predict_result)):
references.append([word_tokenize(predict_result[i]['utterance'])])
candidates.append(word_tokenize(predict_result[i]['prediction']))
metrics['bleu'] = corpus_bleu(references, candidates)
references.append(predict_result[i]['utterance'])
candidates.append(predict_result[i]['prediction'])
# metrics['bleu'] = corpus_bleu(references, candidates)
metrics['bleu'] = sacrebleu.corpus_bleu(candidates, [references], lowercase=True).score
# ERROR Rate
## get all values in ontology
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment