|
| 1 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +from typing import Dict, Pattern |
| 5 | + |
| 6 | +from recognizers_number import BaseNumberExtractor, ItalianCardinalExtractor, ItalianIntegerExtractor, ItalianOrdinalExtractor, BaseNumberParser, ItalianNumberParserConfiguration |
| 7 | + |
| 8 | +from ...resources import ItalianDateTime, BaseDateTime |
| 9 | +from ..extractors import DateTimeExtractor |
| 10 | +from ..parsers import DateTimeParser |
| 11 | +from ..base_configs import BaseDateParserConfiguration, DateTimeUtilityConfiguration |
| 12 | +from ..base_date import BaseDateExtractor, BaseDateParser |
| 13 | +from ..base_time import BaseTimeExtractor |
| 14 | +from ..base_duration import BaseDurationExtractor, BaseDurationParser |
| 15 | +from ..base_dateperiod import BaseDatePeriodExtractor, BaseDatePeriodParser |
| 16 | +from ..base_timeperiod import BaseTimePeriodExtractor, BaseTimePeriodParser |
| 17 | +from ..base_datetime import BaseDateTimeExtractor, BaseDateTimeParser |
| 18 | +from ..base_datetimeperiod import BaseDateTimePeriodExtractor, BaseDateTimePeriodParser |
| 19 | +from ..base_timezone import BaseTimeZoneParser |
| 20 | +from .base_configs import ItalianDateTimeUtilityConfiguration |
| 21 | +from .duration_extractor_config import ItalianDurationExtractorConfiguration |
| 22 | +from .date_extractor_config import ItalianDateExtractorConfiguration |
| 23 | +from .time_extractor_config import ItalianTimeExtractorConfiguration |
| 24 | +from .datetime_extractor_config import ItalianDateTimeExtractorConfiguration |
| 25 | +from .dateperiod_extractor_config import ItalianDatePeriodExtractorConfiguration |
| 26 | +from .timeperiod_extractor_config import ItalianTimePeriodExtractorConfiguration |
| 27 | +from .datetimeperiod_extractor_config import ItalianDateTimePeriodExtractorConfiguration |
| 28 | +from .duration_parser_config import ItalianDurationParserConfiguration |
| 29 | +from .date_parser_config import ItalianDateParserConfiguration |
| 30 | +from .time_parser_config import ItalianTimeParserConfiguration |
| 31 | +from .datetime_parser_config import ItalianDateTimeParserConfiguration |
| 32 | +from .dateperiod_parser_config import ItalianDatePeriodParserConfiguration |
| 33 | +from .timeperiod_parser_config import ItalianTimePeriodParserConfiguration |
| 34 | +from .datetimeperiod_parser_config import ItalianDateTimePeriodParserConfiguration |
| 35 | +from .parsers import ItalianTimeParser |
| 36 | + |
| 37 | + |
| 38 | +class ItalianCommonDateTimeParserConfiguration(BaseDateParserConfiguration): |
| 39 | + @property |
| 40 | + def time_zone_parser(self) -> DateTimeParser: |
| 41 | + self._time_zone_parser |
| 42 | + |
| 43 | + @property |
| 44 | + def check_both_before_after(self) -> Pattern: |
| 45 | + return self._check_both_before_after |
| 46 | + |
| 47 | + @property |
| 48 | + def cardinal_extractor(self) -> BaseNumberExtractor: |
| 49 | + return self._cardinal_extractor |
| 50 | + |
| 51 | + @property |
| 52 | + def integer_extractor(self) -> BaseNumberExtractor: |
| 53 | + return self._integer_extractor |
| 54 | + |
| 55 | + @property |
| 56 | + def ordinal_extractor(self) -> BaseNumberExtractor: |
| 57 | + return self._ordinal_extractor |
| 58 | + |
| 59 | + @property |
| 60 | + def number_parser(self) -> BaseNumberParser: |
| 61 | + return self._number_parser |
| 62 | + |
| 63 | + @property |
| 64 | + def date_extractor(self) -> DateTimeExtractor: |
| 65 | + return self._date_extractor |
| 66 | + |
| 67 | + @property |
| 68 | + def time_extractor(self) -> DateTimeExtractor: |
| 69 | + return self._time_extractor |
| 70 | + |
| 71 | + @property |
| 72 | + def date_time_extractor(self) -> DateTimeExtractor: |
| 73 | + return self._date_time_extractor |
| 74 | + |
| 75 | + @property |
| 76 | + def duration_extractor(self) -> DateTimeExtractor: |
| 77 | + return self._duration_extractor |
| 78 | + |
| 79 | + @property |
| 80 | + def date_period_extractor(self) -> DateTimeExtractor: |
| 81 | + return self._date_period_extractor |
| 82 | + |
| 83 | + @property |
| 84 | + def time_period_extractor(self) -> DateTimeExtractor: |
| 85 | + return self._time_period_extractor |
| 86 | + |
| 87 | + @property |
| 88 | + def date_time_period_extractor(self) -> DateTimeExtractor: |
| 89 | + return self._date_time_period_extractor |
| 90 | + |
| 91 | + @property |
| 92 | + def date_parser(self) -> DateTimeParser: |
| 93 | + return self._date_parser |
| 94 | + |
| 95 | + @property |
| 96 | + def time_parser(self) -> DateTimeParser: |
| 97 | + return self._time_parser |
| 98 | + |
| 99 | + @property |
| 100 | + def date_time_parser(self) -> DateTimeParser: |
| 101 | + return self._date_time_parser |
| 102 | + |
| 103 | + @property |
| 104 | + def duration_parser(self) -> DateTimeParser: |
| 105 | + return self._duration_parser |
| 106 | + |
| 107 | + @property |
| 108 | + def date_period_parser(self) -> DateTimeParser: |
| 109 | + return self._date_period_parser |
| 110 | + |
| 111 | + @property |
| 112 | + def time_period_parser(self) -> DateTimeParser: |
| 113 | + return self._time_period_parser |
| 114 | + |
| 115 | + @property |
| 116 | + def date_time_period_parser(self) -> DateTimeParser: |
| 117 | + return self._date_time_period_parser |
| 118 | + |
| 119 | + @property |
| 120 | + def month_of_year(self) -> Dict[str, int]: |
| 121 | + return self._month_of_year |
| 122 | + |
| 123 | + @property |
| 124 | + def numbers(self) -> Dict[str, int]: |
| 125 | + return self._numbers |
| 126 | + |
| 127 | + @property |
| 128 | + def unit_value_map(self) -> Dict[str, int]: |
| 129 | + return self._unit_value_map |
| 130 | + |
| 131 | + @property |
| 132 | + def season_map(self) -> Dict[str, str]: |
| 133 | + return self._season_map |
| 134 | + |
| 135 | + @property |
| 136 | + def unit_map(self) -> Dict[str, str]: |
| 137 | + return self._unit_map |
| 138 | + |
| 139 | + @property |
| 140 | + def cardinal_map(self) -> Dict[str, int]: |
| 141 | + return self._cardinal_map |
| 142 | + |
| 143 | + @property |
| 144 | + def day_of_week(self) -> Dict[str, int]: |
| 145 | + return self._day_of_week |
| 146 | + |
| 147 | + @property |
| 148 | + def double_numbers(self) -> Dict[str, int]: |
| 149 | + return self._double_numbers |
| 150 | + |
| 151 | + @property |
| 152 | + def utility_configuration(self) -> DateTimeUtilityConfiguration: |
| 153 | + return self._utility_configuration |
| 154 | + |
| 155 | + def __init__(self): |
| 156 | + super().__init__() |
| 157 | + self._time_zone_parser = BaseTimeZoneParser() |
| 158 | + self._utility_configuration = ItalianDateTimeUtilityConfiguration() |
| 159 | + self._unit_map = ItalianDateTime.UnitMap |
| 160 | + self._unit_value_map = ItalianDateTime.UnitValueMap |
| 161 | + self._season_map = ItalianDateTime.SeasonMap |
| 162 | + self._cardinal_map = ItalianDateTime.CardinalMap |
| 163 | + self._day_of_week = ItalianDateTime.DayOfWeek |
| 164 | + self._month_of_year = ItalianDateTime.MonthOfYear |
| 165 | + self._numbers = ItalianDateTime.Numbers |
| 166 | + self._double_numbers = ItalianDateTime.DoubleNumbers |
| 167 | + self._check_both_before_after = ItalianDateTime.CheckBothBeforeAfter |
| 168 | + |
| 169 | + self._cardinal_extractor = ItalianCardinalExtractor() |
| 170 | + self._integer_extractor = ItalianIntegerExtractor() |
| 171 | + self._ordinal_extractor = ItalianOrdinalExtractor() |
| 172 | + |
| 173 | + self._day_of_month = { |
| 174 | + **BaseDateTime.DayOfMonthDictionary, **ItalianDateTime.DayOfMonth} |
| 175 | + self._number_parser = BaseNumberParser( |
| 176 | + ItalianNumberParserConfiguration()) |
| 177 | + self._date_extractor = BaseDateExtractor( |
| 178 | + ItalianDateExtractorConfiguration()) |
| 179 | + self._time_extractor = BaseTimeExtractor( |
| 180 | + ItalianTimeExtractorConfiguration()) |
| 181 | + self._duration_extractor = BaseDurationExtractor( |
| 182 | + ItalianDurationExtractorConfiguration()) |
| 183 | + self._date_period_extractor = BaseDatePeriodExtractor( |
| 184 | + ItalianDatePeriodExtractorConfiguration()) |
| 185 | + self._time_period_extractor = BaseTimePeriodExtractor( |
| 186 | + ItalianTimePeriodExtractorConfiguration()) |
| 187 | + self._date_time_extractor = BaseDateTimeExtractor( |
| 188 | + ItalianDateTimeExtractorConfiguration()) |
| 189 | + self._date_time_period_extractor = BaseDateTimePeriodExtractor( |
| 190 | + ItalianDateTimePeriodExtractorConfiguration()) |
| 191 | + self._duration_parser = BaseDurationParser( |
| 192 | + ItalianDurationParserConfiguration(self)) |
| 193 | + self._date_parser = BaseDateParser(ItalianDateParserConfiguration(self)) |
| 194 | + self._time_parser = ItalianTimeParser( |
| 195 | + ItalianTimeParserConfiguration(self)) |
| 196 | + self._date_period_parser = BaseDatePeriodParser( |
| 197 | + ItalianDatePeriodParserConfiguration(self)) |
| 198 | + self._time_period_parser = BaseTimePeriodParser( |
| 199 | + ItalianTimePeriodParserConfiguration(self)) |
| 200 | + self._date_time_parser = BaseDateTimeParser( |
| 201 | + ItalianDateTimeParserConfiguration(self)) |
| 202 | + self._date_time_period_parser = BaseDateTimePeriodParser( |
| 203 | + ItalianDateTimePeriodParserConfiguration(self)) |
0 commit comments