Exemple #1
0
 def update_metrics(self, batch: Dict[str, Any],
                    output: Union[torch.Tensor, Dict[str, torch.Tensor],
                                  Iterable[torch.Tensor], Any],
                    prediction: Dict[str, Any], metric: Union[MetricDict,
                                                              Metric]):
     return SpanRankingSemanticRoleLabeler.update_metrics(
         self, batch, {'prediction': prediction}, tuple(metric.values()))
Exemple #2
0
 def prediction_to_result(self, prediction: Dict[str, Any],
                          batch: Dict[str, Any]) -> List:
     return SpanRankingSemanticRoleLabeler.format_dict_to_results(
         batch['token'],
         prediction,
         exclusive_offset=True,
         with_predicate=True,
         with_argument=self.config.get('with_argument', ' '),
         label_first=True)
Exemple #3
0
 def decode_output(self,
                   output: Dict[str, Any],
                   mask: torch.BoolTensor,
                   batch: Dict[str, Any],
                   decoder, **kwargs) -> Union[Dict[str, Any], Any]:
     return SpanRankingSemanticRoleLabeler.decode_output(self, output, batch)
Exemple #4
0
 def input_is_flat(self, data) -> bool:
     return SpanRankingSemanticRoleLabeler.input_is_flat(self, data)
Exemple #5
0
 def build_metric(self, **kwargs):
     predicate_f1, end_to_end_f1 = SpanRankingSemanticRoleLabeler.build_metric(self, **kwargs)
     return MetricDict({'predicate': predicate_f1, 'e2e': end_to_end_f1})