from src.detections.detection import Detection from typing import List, Tuple, Optional class DateDetection(Detection): TYPE_NAME = "date" class AnnotationPart: TWO_DIGITS_DAY = "DD" ONE_DIGIT_DAY = "D" TWO_DIGIT_MONTH = "MM" ONE_DIGIT_MONTH = "M" FOUR_DIGIT_YEAR = "YYYY" TWO_DIGIT_YEAR = "YY" TEXT_MONTH = "MMM" OTHER = "OTHER" def __init__( self, format: Optional[List[Tuple[AnnotationPart, str]]] = None ) -> None: """ The annotation representing a date value. :param format: the format of the date, e.g. [(AnnotationPart.TWO_DIGITS_DAY, "01"), (AnnotationPart.OTHER, ".") ...] :type format: Optional[List[Tuple[str, str]]] """ super().__init__() self.format = format def __eq__(self, other) -> bool: return self.format == other.format and super().__eq__(other)