def __init__(self): BaseDateParserConfiguration.__init__(self) self._utility_configuration = SpanishDateTimeUtilityConfiguration() self._unit_map = SpanishDateTime.UnitMap self._unit_value_map = SpanishDateTime.UnitValueMap self._season_map = SpanishDateTime.SeasonMap self._cardinal_map = SpanishDateTime.CardinalMap self._day_of_week = SpanishDateTime.DayOfWeek self._month_of_year = SpanishDateTime.MonthOfYear self._numbers = SpanishDateTime.Numbers self._double_numbers = SpanishDateTime.DoubleNumbers self._check_both_before_after = SpanishDateTime.CheckBothBeforeAfter self._cardinal_extractor = SpanishCardinalExtractor() self._integer_extractor = SpanishIntegerExtractor() self._ordinal_extractor = SpanishOrdinalExtractor() self._number_parser = BaseNumberParser( SpanishNumberParserConfiguration()) self._date_extractor = BaseDateExtractor( SpanishDateExtractorConfiguration()) self._time_extractor = BaseTimeExtractor( SpanishTimeExtractorConfiguration()) self._duration_extractor = BaseDurationExtractor( SpanishDurationExtractorConfiguration()) self._date_period_extractor = BaseDatePeriodExtractor( SpanishDatePeriodExtractorConfiguration()) self._time_period_extractor = BaseTimePeriodExtractor( SpanishTimePeriodExtractorConfiguration()) self._date_time_extractor = BaseDateTimeExtractor( SpanishDateTimeExtractorConfiguration()) self._date_time_period_extractor = BaseDateTimePeriodExtractor( SpanishDateTimePeriodExtractorConfiguration()) self._duration_parser = BaseDurationParser( SpanishDurationParserConfiguration(self)) self._date_parser = BaseDateParser( SpanishDateParserConfiguration(self)) self._time_parser = BaseTimeParser( SpanishTimeParserConfiguration(self)) self._date_period_parser = BaseDatePeriodParser( SpanishDatePeriodParserConfiguration(self)) self._time_period_parser = BaseTimePeriodParser( SpanishTimePeriodParserConfiguration(self)) self._date_time_parser = BaseDateTimeParser( SpanishDateTimeParserConfiguration(self)) self._date_time_period_parser = BaseDateTimePeriodParser( SpanishDateTimePeriodParserConfiguration(self))
def __init__(self): self._year_period_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.YearPeriodRegex) self._previous_prefix_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.PastRegex) self._simple_cases_regexes = [ self._year_period_regex, RegExpUtility.get_safe_reg_exp(SpanishDateTime.SimpleCasesRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.DayBetweenRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.OneWordPeriodRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.MonthWithYearRegex), RegExpUtility.get_safe_reg_exp( SpanishDateTime.MonthNumWithYearRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.YearRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.WeekOfMonthRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.WeekOfYearRegex), RegExpUtility.get_safe_reg_exp( SpanishDateTime.MonthFrontBetweenRegex), RegExpUtility.get_safe_reg_exp( SpanishDateTime.MonthFrontSimpleCasesRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.QuarterRegex), RegExpUtility.get_safe_reg_exp( SpanishDateTime.QuarterRegexYearFront), RegExpUtility.get_safe_reg_exp(SpanishDateTime.SeasonRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.RestOfDateRegex), RegExpUtility.get_safe_reg_exp( SpanishDateTime.LaterEarlyPeriodRegex), RegExpUtility.get_safe_reg_exp( SpanishDateTime.WeekWithWeekDayRangeRegex), RegExpUtility.get_safe_reg_exp( SpanishDateTime.YearPlusNumberRegex), RegExpUtility.get_safe_reg_exp(SpanishDateTime.WhichWeekRegex), RegExpUtility.get_safe_reg_exp( SpanishDateTime.ReferenceDatePeriodRegex), ] self._check_both_before_after = SpanishDateTime.CheckBothBeforeAfter self._time_unit_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.TimeUnitRegex) self._within_next_prefix_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.WithinNextPrefixRegex) self._illegal_year_regex = RegExpUtility.get_safe_reg_exp( BaseDateTime.IllegalYearRegex) self._year_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.YearRegex) self._till_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.TillRegex) self._followed_unit = RegExpUtility.get_safe_reg_exp( SpanishDateTime.FollowedDateUnit) self._number_combined_with_unit = RegExpUtility.get_safe_reg_exp( SpanishDateTime.NumberCombinedWithDateUnit) self._past_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.PastRegex) self._future_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.FutureRegex) self._week_of_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.WeekOfRegex) self._month_of_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.MonthOfRegex) self._date_unit_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.DateUnitRegex) self._in_connector_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.InConnectorRegex) self._range_unit_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.RangeUnitRegex) self._all_half_year_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.AllHalfYearRegex) self.from_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.FromRegex) self.connector_and_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.ConnectorAndRegex) self.between_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.BetweenRegex) self._date_point_extractor = BaseDateExtractor( SpanishDateExtractorConfiguration()) self._integer_extractor = SpanishIntegerExtractor() self._number_parser = BaseNumberParser( SpanishNumberParserConfiguration()) self._duration_extractor = BaseDurationExtractor( SpanishDurationExtractorConfiguration()) self._now_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.NowRegex) self._future_suffix_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.FutureSuffixRegex) self._ago_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.AgoRegex) self._later_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.LaterRegex) self._less_than_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.LessThanRegex) self._more_than_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.MoreThanRegex) self._duration_date_restrictions = SpanishDateTime.DurationDateRestrictions self._month_num_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.MonthNumRegex) self._century_suffix_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.CenturySuffixRegex) self._check_both_before_after = False self._cardinal_extractor = SpanishCardinalExtractor() self._ordinal_extractor = SpanishOrdinalExtractor() self._decade_with_century_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.DecadeWithCenturyRegex) self._previous_prefix_regex = RegExpUtility.get_safe_reg_exp( SpanishDateTime.PreviousPrefixRegex)
def initialize_configuration(self): # region English self.register_model( 'NumberModel', Culture.English, lambda options: NumberModel( AgnosticNumberParserFactory.get_parser( ParserType.NUMBER, EnglishNumberParserConfiguration()), EnglishNumberExtractor(NumberMode.PURE_NUMBER))) self.register_model( 'OrdinalModel', Culture.English, lambda options: OrdinalModel( AgnosticNumberParserFactory.get_parser( ParserType.ORDINAL, EnglishNumberParserConfiguration()), EnglishOrdinalExtractor())) self.register_model( 'PercentModel', Culture.English, lambda options: PercentModel( AgnosticNumberParserFactory.get_parser( ParserType.PERCENTAGE, EnglishNumberParserConfiguration()), EnglishPercentageExtractor())) # endregion # region German # self.register_model('NumberModel', Culture.German, lambda options: NumberModel( # AgnosticNumberParserFactory.get_parser( # ParserType.NUMBER, GermanNumberParserConfiguration()), # GermanNumberExtractor(NumberMode.PURE_NUMBER) # )) # self.register_model('OrdinalModel', Culture.German, lambda options: OrdinalModel( # AgnosticNumberParserFactory.get_parser( # ParserType.ORDINAL, GermanNumberParserConfiguration()), # GermanOrdinalExtractor() # )) # self.register_model('PercentModel', Culture.German, lambda options: PercentModel( # AgnosticNumberParserFactory.get_parser( # ParserType.PERCENTAGE, GermanNumberParserConfiguration()), # GermanPercentageExtractor() # )) # endregion # region Chinese self.register_model( 'NumberModel', Culture.Chinese, lambda options: NumberModel( AgnosticNumberParserFactory.get_parser( ParserType.NUMBER, ChineseNumberParserConfiguration()), ChineseNumberExtractor())) self.register_model( 'OrdinalModel', Culture.Chinese, lambda options: OrdinalModel( AgnosticNumberParserFactory.get_parser( ParserType.ORDINAL, ChineseNumberParserConfiguration()), ChineseOrdinalExtractor())) self.register_model( 'PercentModel', Culture.Chinese, lambda options: PercentModel( AgnosticNumberParserFactory.get_parser( ParserType.PERCENTAGE, ChineseNumberParserConfiguration()), ChinesePercentageExtractor())) # endregion # region Japanese self.register_model( 'NumberModel', Culture.Japanese, lambda options: NumberModel( AgnosticNumberParserFactory.get_parser( ParserType.NUMBER, JapaneseNumberParserConfiguration()), JapaneseNumberExtractor())) self.register_model( 'OrdinalModel', Culture.Japanese, lambda options: OrdinalModel( AgnosticNumberParserFactory.get_parser( ParserType.ORDINAL, JapaneseNumberParserConfiguration()), JapaneseOrdinalExtractor())) self.register_model( 'PercentModel', Culture.Japanese, lambda options: PercentModel( AgnosticNumberParserFactory.get_parser( ParserType.PERCENTAGE, JapaneseNumberParserConfiguration() ), JapanesePercentageExtractor())) # endregion # region Spanish self.register_model( 'NumberModel', Culture.Spanish, lambda options: NumberModel( AgnosticNumberParserFactory.get_parser( ParserType.NUMBER, SpanishNumberParserConfiguration()), SpanishNumberExtractor(NumberMode.PURE_NUMBER))) self.register_model( 'OrdinalModel', Culture.Spanish, lambda options: OrdinalModel( AgnosticNumberParserFactory.get_parser( ParserType.ORDINAL, SpanishNumberParserConfiguration()), SpanishOrdinalExtractor())) self.register_model( 'PercentModel', Culture.Spanish, lambda options: PercentModel( AgnosticNumberParserFactory.get_parser( ParserType.PERCENTAGE, SpanishNumberParserConfiguration()), SpanishPercentageExtractor())) # endregion # region Portuguese self.register_model( 'NumberModel', Culture.Portuguese, lambda options: NumberModel( AgnosticNumberParserFactory.get_parser( ParserType.NUMBER, PortugueseNumberParserConfiguration()), PortugueseNumberExtractor(NumberMode.PURE_NUMBER))) self.register_model( 'OrdinalModel', Culture.Portuguese, lambda options: OrdinalModel( AgnosticNumberParserFactory.get_parser( ParserType.ORDINAL, PortugueseNumberParserConfiguration()), PortugueseOrdinalExtractor())) self.register_model( 'PercentModel', Culture.Portuguese, lambda options: PercentModel( AgnosticNumberParserFactory.get_parser( ParserType.PERCENTAGE, PortugueseNumberParserConfiguration( )), PortuguesePercentageExtractor())) # endregion # region French self.register_model( 'NumberModel', Culture.French, lambda options: NumberModel( AgnosticNumberParserFactory.get_parser( ParserType.NUMBER, FrenchNumberParserConfiguration()), FrenchNumberExtractor(NumberMode.PURE_NUMBER))) self.register_model( 'OrdinalModel', Culture.French, lambda options: OrdinalModel( AgnosticNumberParserFactory.get_parser( ParserType.ORDINAL, FrenchNumberParserConfiguration()), FrenchOrdinalExtractor())) self.register_model( 'PercentModel', Culture.French, lambda options: PercentModel( AgnosticNumberParserFactory.get_parser( ParserType.PERCENTAGE, FrenchNumberParserConfiguration()), FrenchPercentageExtractor()))