diff --git a/forte/data/data_pack.py b/forte/data/data_pack.py index 3c20e9978..0100ca618 100644 --- a/forte/data/data_pack.py +++ b/forte/data/data_pack.py @@ -1598,12 +1598,14 @@ def require_annotations(entry_class=Annotation) -> bool: # If we don't have any annotations but the items to check requires them, # then we simply yield from an empty list. + # changed form using len(annotations) to num_annotations directly for + # improving the performance. if ( - len(self.annotations) == 0 + self.num_annotations == 0 and isinstance(range_annotation, Annotation) and require_annotations(Annotation) ) or ( - len(self.audio_annotations) == 0 + self.num_audio_annotations == 0 and isinstance(range_annotation, AudioAnnotation) and require_annotations(AudioAnnotation) ):