Skip to content
Snippets Groups Projects
date.py 929 B
Newer Older
from src.detections.detection import Detection
Michał Pogoda's avatar
Michał Pogoda committed
from typing import List, Tuple, Optional

    TYPE_NAME = "date"
Michał Pogoda's avatar
Michał Pogoda committed
    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"
Michał Pogoda's avatar
Michał Pogoda committed

    def __init__(
        self, format: Optional[List[Tuple[AnnotationPart, str]]] = None
    ) -> None:
Michał Pogoda's avatar
Michał Pogoda committed
        """
        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__()
Michał Pogoda's avatar
Michał Pogoda committed
        self.format = format
Michał Pogoda's avatar
Michał Pogoda committed
    def __eq__(self, other) -> bool:
Michał Pogoda's avatar
Michał Pogoda committed
        return self.format == other.format and super().__eq__(other)