Evaluation of a single example pair.
| 36 | |
| 37 | @dataclasses.dataclass |
| 38 | class Score: |
| 39 | """Evaluation of a single example pair.""" |
| 40 | |
| 41 | # pylint: disable=invalid-name because L is more readable here. |
| 42 | rouge_L: float |
| 43 | rouge_1: float |
| 44 | label: Label |
| 45 | bleurt: Optional[float] = None |
| 46 | qsim: Optional[bool] = None |
| 47 | |
| 48 | def to_dict(self): |
| 49 | """Translates class into dictionary, excluding unspecified values.""" |
| 50 | scores = { |
| 51 | "rougeL": self.rouge_L, |
| 52 | "rouge_1": self.rouge_1, |
| 53 | "label": f"{self.label}", |
| 54 | } |
| 55 | if self.qsim is not None: |
| 56 | scores["qsim"]: self.qsim |
| 57 | if self.bleurt is not None: |
| 58 | scores["bleurt"] = self.bleurt |
| 59 | return scores |
| 60 | |
| 61 | def __str__(self): |
| 62 | return json.dumps(self.to_dict()) |
| 63 | |
| 64 | |
| 65 | @dataclasses.dataclass |
no outgoing calls
no test coverage detected
searching dependent graphs…