Unverified Commit c4632655 authored by Leo Gao's avatar Leo Gao Committed by GitHub
Browse files

Merge pull request #168 from EleutherAI/translation-fix

fix translation scoring format
parents 5aa601f3 3a2b7df4
...@@ -2,3 +2,4 @@ env ...@@ -2,3 +2,4 @@ env
*.pyc *.pyc
data/ data/
lm_cache lm_cache
.idea
\ No newline at end of file
import math import math
from collections import Iterable from collections import Iterable
from pprint import pprint
import numpy as np import numpy as np
import sacrebleu import sacrebleu
...@@ -124,7 +125,7 @@ def _sacreformat(refs, preds): ...@@ -124,7 +125,7 @@ def _sacreformat(refs, preds):
# Must become List[List[str]] with the inner list corresponding to preds # Must become List[List[str]] with the inner list corresponding to preds
if not is_non_str_iterable(refs): if not is_non_str_iterable(refs):
refs = list(refs) refs = list(refs)
if not is_non_str_iterable(refs): if not is_non_str_iterable(refs[0]):
refs = [[ref] for ref in refs] refs = [[ref] for ref in refs]
refs = list(zip(*refs)) refs = list(zip(*refs))
# Note the number of refs in each ref list much match the number of preds # Note the number of refs in each ref list much match the number of preds
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment