Skip to content

Commit

Permalink
Update bertscore.py (huggingface#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
PassionateLooker authored Oct 5, 2020
1 parent 97eeaaa commit 80ffe60
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions metrics/bertscore/bertscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
Args:
`predictions` (list of str): prediction/candidate sentences
`refereces` (list of str or list of list of str): reference sentences
`references` (list of str or list of list of str): reference sentences
`lang` (str): language of the sentences; required (e.g. 'en')
`model_type` (str): bert specification, default using the suggested
model for the target langauge; has to specify at least one of
model for the target language; has to specify at least one of
`model_type` or `lang`
`num_layers` (int): the layer of representation to use.
default using the number of layer tuned on WMT16 correlation data
default using the number of layers tuned on WMT16 correlation data
`verbose` (bool): turn on intermediate status update
`idf` (bool or dict): use idf weighting, can also be a precomputed idf_dict
`device` (str): on which the contextual embedding model will be allocated on.
Expand Down Expand Up @@ -135,15 +135,15 @@ def _compute(

def add_batch(self, predictions=None, references=None, **kwargs):
"""Add a batch of predictions and references for the metric's stack."""
# Refefences can be strings or lists of strings
# References can be strings or lists of strings
# Let's change strings to lists of strings with one element
if references is not None:
references = [[ref] if isinstance(ref, str) else ref for ref in references]
super().add_batch(predictions=predictions, references=references, **kwargs)

def add(self, prediction=None, reference=None, **kwargs):
"""Add one prediction and reference for the metric's stack."""
# Refefences can be strings or lists of strings
# References can be strings or lists of strings
# Let's change strings to lists of strings with one element
if isinstance(reference, str):
reference = [reference]
Expand Down

0 comments on commit 80ffe60

Please sign in to comment.