from src.detections import DateDetection from src.detectors.date.date import DateDetector def test_detect_dates_pl(): detector = DateDetector("pl") text = "W dniu 1.01.2022 sprzedałem kota. 5 kwietnia 2021 roku kupiłem psa." found_dates = detector.detect(text, dict()) format_date1 = [ (DateDetection.AnnotationPart.TWO_DIGITS_DAY, "01"), # Only supports two digits for now (DateDetection.AnnotationPart.OTHER, "."), (DateDetection.AnnotationPart.TWO_DIGIT_MONTH, "01"), (DateDetection.AnnotationPart.OTHER, "."), (DateDetection.AnnotationPart.FOUR_DIGIT_YEAR, "2022") ] format_date2 = [ (DateDetection.AnnotationPart.TWO_DIGITS_DAY, "05"), # Only supports two digits for now (DateDetection.AnnotationPart.OTHER, " "), (DateDetection.AnnotationPart.TEXT_MONTH, "kwietnia"), (DateDetection.AnnotationPart.OTHER, " "), (DateDetection.AnnotationPart.FOUR_DIGIT_YEAR, "2021"), ] assert found_dates == [(7, 16, DateDetection(format_date1)), (34, 49, DateDetection(format_date2))]