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() # TODO When the implementation for these properties is added, change the None values to their respective Regexps self._time_unit_regex = None self._cardinal_extractor = None
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 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()))
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.PastSuffixRegex), RegExpUtility.get_safe_reg_exp(FrenchDateTime.NextSuffixRegex), RegExpUtility.get_safe_reg_exp(FrenchDateTime.ThisPrefixRegex), RegExpUtility.get_safe_reg_exp( FrenchDateTime.LaterEarlyPeriodRegex), RegExpUtility.get_safe_reg_exp( FrenchDateTime.WeekWithWeekDayRangeRegex) ] 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._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())