コード例 #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()))
コード例 #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)
コード例 #3
0
ファイル: rank_srl.py プロジェクト: Tirwanove/HanLP
 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)
コード例 #4
0
ファイル: rank_srl.py プロジェクト: Tirwanove/HanLP
 def input_is_flat(self, data) -> bool:
     return SpanRankingSemanticRoleLabeler.input_is_flat(self, data)
コード例 #5
0
ファイル: rank_srl.py プロジェクト: Tirwanove/HanLP
 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})