Exemplo n.º 1
0
    def __init__(self):
        super().__init__()

        self._utility_configuration = FrenchDateTimeUtilityConfiguration()
        self._unit_map = FrenchDateTime.UnitMap
        self._unit_value_map = FrenchDateTime.UnitValueMap
        self._season_map = FrenchDateTime.SeasonMap
        self._cardinal_map = FrenchDateTime.CardinalMap
        self._day_of_week = FrenchDateTime.DayOfWeek
        self._month_of_year = FrenchDateTime.MonthOfYear
        self._numbers = FrenchDateTime.Numbers
        self._double_numbers = FrenchDateTime.DoubleNumbers
        self._cardinal_extractor = FrenchCardinalExtractor()
        self._integer_extractor = FrenchIntegerExtractor()
        self._ordinal_extractor = FrenchOrdinalExtractor()
        self._day_of_month = {**BaseDateTime.DayOfMonthDictionary, **FrenchDateTime.DayOfMonth}
        self._number_parser = BaseNumberParser(FrenchNumberParserConfiguration())
        self._date_extractor = BaseDateExtractor(FrenchDateExtractorConfiguration())
        self._time_extractor = BaseTimeExtractor(FrenchTimeExtractorConfiguration())
        self._duration_extractor = BaseDurationExtractor(FrenchDurationExtractorConfiguration())
        self._date_period_extractor = BaseDatePeriodExtractor(FrenchDatePeriodExtractorConfiguration())
        self._time_period_extractor = BaseTimePeriodExtractor(FrenchTimePeriodExtractorConfiguration())
        self._date_time_extractor = BaseDateTimeExtractor(FrenchDateTimeExtractorConfiguration())
        self._date_time_period_extractor = BaseDateTimePeriodExtractor(FrenchDateTimePeriodExtractorConfiguration())
        self._duration_parser = BaseDurationParser(FrenchDurationParserConfiguration(self))
        self._date_parser = BaseDateParser(FrenchDateParserConfiguration(self))
        self._time_parser = FrenchTimeParser(FrenchTimeParserConfiguration(self))
        self._date_period_parser = BaseDatePeriodParser(FrenchDatePeriodParserConfiguration(self))
        self._time_period_parser = BaseTimePeriodParser(FrenchTimePeriodParserConfiguration(self))
        self._date_time_parser = BaseDateTimeParser(FrenchDateTimeParserConfiguration(self))
        self._date_time_period_parser = BaseDateTimePeriodParser(FrenchDateTimePeriodParserConfiguration(self))
Exemplo n.º 2
0
    def __init__(self):
        if FrenchDateTime.DefaultLanguageFallback == Constants.DEFAULT_LANGUAGE_FALLBACK_DMY:
            date_extractor_4 = FrenchDateTime.DateExtractor5
            date_extractor_5 = FrenchDateTime.DateExtractor4
        else:
            date_extractor_4 = FrenchDateTime.DateExtractor4
            date_extractor_5 = FrenchDateTime.DateExtractor5

        self._date_regex_list = [
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor1),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor2),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor3),
            RegExpUtility.get_safe_reg_exp(date_extractor_4),
            RegExpUtility.get_safe_reg_exp(date_extractor_5),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor6),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor7),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor8),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor9),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractorA),
        ]

        self._implicit_date_list = [
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.OnRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.RelaxedOnRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.SpecialDayRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.ThisRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.LastDateRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.NextDateRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.StrictWeekDay),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.WeekDayOfMonthRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.SpecialDate),
        ]
        self._month_end = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.MonthEnd)
        self._of_month = RegExpUtility.get_safe_reg_exp(FrenchDateTime.OfMonth)
        self._date_unit_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.DateUnitRegex)
        self._for_the_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.ForTheRegex)
        self._week_day_and_day_of_month_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WeekDayAndDayOfMonthRegex)
        self._relative_month_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.RelativeMonthRegex)
        self._week_day_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WeekDayRegex)
        self._day_of_week = FrenchDateTime.DayOfWeek
        self._ordinal_extractor = FrenchOrdinalExtractor()
        self._integer_extractor = FrenchIntegerExtractor()
        self._number_parser = BaseNumberParser(
            FrenchNumberParserConfiguration())
        self._duration_extractor = BaseDurationExtractor(
            FrenchDurationExtractorConfiguration())
        self._utility_configuration = FrenchDateTimeUtilityConfiguration()
    def __init__(self):
        self._simple_cases_regexes = [
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.SimpleCasesRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.BetweenRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.OneWordPeriodRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.MonthWithYear),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.MonthNumWithYear),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.YearRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.WeekDayOfMonthRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.WeekOfYearRegex),
            RegExpUtility.get_safe_reg_exp(
                FrenchDateTime.MonthFrontBetweenRegex),
            RegExpUtility.get_safe_reg_exp(
                FrenchDateTime.MonthFrontSimpleCasesRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.QuarterRegex),
            RegExpUtility.get_safe_reg_exp(
                FrenchDateTime.QuarterRegexYearFront),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.AllHalfYearRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.SeasonRegex),
            RegExpUtility.get_safe_reg_exp(
                FrenchDateTime.LaterEarlyPeriodRegex),
            RegExpUtility.get_safe_reg_exp(
                FrenchDateTime.WeekWithWeekDayRangeRegex)
        ]
        self._check_both_before_after = FrenchDateTime.CheckBothBeforeAfter
        self._illegal_year_regex = RegExpUtility.get_safe_reg_exp(
            BaseDateTime.IllegalYearRegex)
        self._year_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.YearRegex)
        self._till_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.TillRegex)
        self._followed_unit = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.FollowedDateUnit)
        self._number_combined_with_unit = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.NumberCombinedWithDateUnit)
        self._past_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.PastSuffixRegex)
        self._future_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.NextSuffixRegex)
        self._week_of_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WeekOfRegex)
        self._month_of_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.MonthOfRegex)
        self._date_unit_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.DateUnitRegex)
        self._within_next_prefix_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WithinNextPrefixRegex)
        self._in_connector_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.InConnectorRegex)
        self._range_unit_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.RangeUnitRegex)

        self.from_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.FromRegex)
        self.connector_and_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.ConnectorAndRegex)
        self.before_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.BeforeRegex2)

        self._date_point_extractor = BaseDateExtractor(
            FrenchDateExtractorConfiguration())
        self._integer_extractor = FrenchIntegerExtractor()
        self._number_parser = BaseNumberParser(
            FrenchNumberParserConfiguration())
        self._duration_extractor = BaseDurationExtractor(
            FrenchDurationExtractorConfiguration())
        self._now_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.NowRegex)
        self._future_suffix_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.FutureSuffixRegex
        )
        self._ago_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.AgoRegex
        )
        self._later_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.LaterRegex
        )
        self._less_than_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.LessThanRegex
        )
        self._more_than_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.MoreThanRegex
        )
        self._duration_date_restrictions = FrenchDateTime.DurationDateRestrictions
        self._year_period_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.YearPeriodRegex
        )
        self._month_num_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.MonthNumRegex
        )
        self._century_suffix_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.CenturySuffixRegex
        )
        self._ordinal_extractor = FrenchOrdinalExtractor()
        self._previous_prefix_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.PreviousPrefixRegex
        )
        self._cardinal_extractor = FrenchCardinalExtractor()
        # TODO When the implementation for these properties is added, change the None values to their respective Regexps
        self._time_unit_regex = None
Exemplo n.º 4
0
    def __init__(self):
        self._check_both_before_after = False
        if FrenchDateTime.DefaultLanguageFallback == Constants.DEFAULT_LANGUAGE_FALLBACK_DMY:
            date_extractor_4 = FrenchDateTime.DateExtractor5
            date_extractor_5 = FrenchDateTime.DateExtractor4
            date_extractor_6 = FrenchDateTime.DateExtractor7
            date_extractor_7 = FrenchDateTime.DateExtractor6
        else:
            date_extractor_4 = FrenchDateTime.DateExtractor4
            date_extractor_5 = FrenchDateTime.DateExtractor5
            date_extractor_6 = FrenchDateTime.DateExtractor6
            date_extractor_7 = FrenchDateTime.DateExtractor7

        self._date_regex_list = [
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor1),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor2),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor3),
            RegExpUtility.get_safe_reg_exp(date_extractor_4),
            RegExpUtility.get_safe_reg_exp(date_extractor_5),
            RegExpUtility.get_safe_reg_exp(date_extractor_6),
            RegExpUtility.get_safe_reg_exp(date_extractor_7),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor8),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractor9),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.DateExtractorA),
        ]

        self._implicit_date_list = [
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.OnRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.RelaxedOnRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.SpecialDayRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.ThisRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.LastDateRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.NextDateRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.StrictWeekDay),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.WeekDayOfMonthRegex),
            RegExpUtility.get_safe_reg_exp(FrenchDateTime.SpecialDate),
        ]
        self._month_end = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.MonthEnd)
        self._of_month = RegExpUtility.get_safe_reg_exp(FrenchDateTime.OfMonth)
        self._date_unit_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.DateUnitRegex)
        self._for_the_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.ForTheRegex)
        self._week_day_and_day_of_month_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WeekDayAndDayOfMonthRegex)
        self._relative_month_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.RelativeMonthRegex)
        self._week_day_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WeekDayRegex)
        self._day_of_week = FrenchDateTime.DayOfWeek
        self._ordinal_extractor = FrenchOrdinalExtractor()
        self._integer_extractor = FrenchIntegerExtractor()
        self._number_parser = BaseNumberParser(
            FrenchNumberParserConfiguration())
        self._duration_extractor = BaseDurationExtractor(
            FrenchDurationExtractorConfiguration())
        self._utility_configuration = FrenchDateTimeUtilityConfiguration()
        self._range_connector_symbol_regex = RegExpUtility.get_safe_reg_exp(
            BaseDateTime.RangeConnectorSymbolRegex)
        self._strict_relative_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.StrictRelativeRegex)
        self._year_suffix = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.YearSuffix)
        self._month_of_year = FrenchDateTime.MonthOfYear
        self._prefix_article_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.PrefixArticleRegex)
        self._week_day_end = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WeekDayEnd)
        self._more_than_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.MoreThanRegex)
        self._less_than_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.LessThanRegex)
        self._in_connector_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.InConnectorRegex)
        self._range_unit_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.RangeUnitRegex)
        self._since_year_suffix_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.SinceYearSuffixRegex)
        self._week_day_and_day_regex = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WeekDayAndDayRegex)
        self._week_day_start = RegExpUtility.get_safe_reg_exp(
            FrenchDateTime.WeekDayStart)
        self._check_both_before_after = FrenchDateTime.CheckBothBeforeAfter