dfki-nlp commited on
Commit
c81d27a
1 Parent(s): c7db18a

Update transformer_re_text_classification2.py

Browse files
transformer_re_text_classification2.py CHANGED
@@ -293,6 +293,10 @@ class TransformerRETextClassificationTaskModule2(_TransformerReTextClassificatio
293
  entities: Sequence[Span] = document[self.entity_annotation]
294
 
295
  relations: Sequence[BinaryRelation] = document[self.relation_annotation]
 
 
 
 
296
 
297
  partitions: Sequence[Optional[Span]]
298
  if self.partition_annotation is not None:
@@ -424,7 +428,8 @@ class TransformerRETextClassificationTaskModule2(_TransformerReTextClassificatio
424
 
425
  # lots of logging from here on
426
  log_this_example = (
427
- self.log_first_n_examples is not None
 
428
  and self._logged_examples_counter <= self.log_first_n_examples
429
  )
430
  if log_this_example:
 
293
  entities: Sequence[Span] = document[self.entity_annotation]
294
 
295
  relations: Sequence[BinaryRelation] = document[self.relation_annotation]
296
+ # if no relations are predefined, use None so that enumerate_entities yields all pairs
297
+ # should be fixed to a parameter "generate_all" or "restrict_to_existing_relations"
298
+ if len(relations) == 0:
299
+ relations = None
300
 
301
  partitions: Sequence[Optional[Span]]
302
  if self.partition_annotation is not None:
 
428
 
429
  # lots of logging from here on
430
  log_this_example = (
431
+ relations is not None
432
+ and self.log_first_n_examples is not None
433
  and self._logged_examples_counter <= self.log_first_n_examples
434
  )
435
  if log_this_example: