Ejemplo n.º 1
0
    def __init__(self):
        BaseDateParserConfiguration.__init__(self)

        self._utility_configuration = PortugueseDateTimeUtilityConfiguration()
        self._unit_map = PortugueseDateTime.UnitMap
        self._unit_value_map = PortugueseDateTime.UnitValueMap
        self._season_map = PortugueseDateTime.SeasonMap
        self._cardinal_map = PortugueseDateTime.CardinalMap
        self._day_of_week = PortugueseDateTime.DayOfWeek
        self._month_of_year = PortugueseDateTime.MonthOfYear
        self._numbers = PortugueseDateTime.Numbers
        self._double_numbers = PortugueseDateTime.DoubleNumbers
        self._cardinal_extractor = PortugueseCardinalExtractor()
        self._integer_extractor = PortugueseIntegerExtractor()
        self._ordinal_extractor = PortugueseOrdinalExtractor()
        self._check_both_before_after = PortugueseDateTime.CheckBothBeforeAfter
        self._time_zone_parser = BaseTimeZoneParser()
        self._number_parser = BaseNumberParser(
            PortugueseNumberParserConfiguration())
        self._date_extractor = BaseDateExtractor(
            PortugueseDateExtractorConfiguration())
        self._time_extractor = BaseTimeExtractor(
            PortugueseTimeExtractorConfiguration())
        self._duration_extractor = BaseDurationExtractor(
            PortugueseDurationExtractorConfiguration())
        self._date_period_extractor = BaseDatePeriodExtractor(
            PortugueseDatePeriodExtractorConfiguration())
        self._time_period_extractor = BaseTimePeriodExtractor(
            PortugueseTimePeriodExtractorConfiguration())
        self._date_time_extractor = BaseDateTimeExtractor(
            PortugueseDateTimeExtractorConfiguration())
        self._date_time_period_extractor = BaseDateTimePeriodExtractor(
            PortugueseDateTimePeriodExtractorConfiguration())
        self._duration_parser = BaseDurationParser(
            PortugueseDurationParserConfiguration(self))
        self._date_parser = BaseDateParser(
            PortugueseDateParserConfiguration(self))
        self._time_parser = PortugueseTimeParser(
            PortugueseTimeParserConfiguration(self))
        self._date_period_parser = BaseDatePeriodParser(
            PortugueseDatePeriodParserConfiguration(self))
        self._time_period_parser = BaseTimePeriodParser(
            PortugueseTimePeriodParserConfiguration(self))
        self._date_time_parser = BaseDateTimeParser(
            PortugueseDateTimeParserConfiguration(self))
        self._date_time_period_parser = BaseDateTimePeriodParser(
            PortugueseDateTimePeriodParserConfiguration(self))
Ejemplo n.º 2
0
    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()))