def __init__(self, culture_info: CultureInfo):
     if culture_info is None:
         culture_info = CultureInfo(Culture.Spanish)
     super().__init__(culture_info)
     self._unit_num_extractor = SpanishNumberExtractor()
     self._build_prefix = SpanishNumericWithUnit.BuildPrefix
     self._build_suffix = SpanishNumericWithUnit.BuildSuffix
Exemple #2
0
 def __init__(self, culture_info: CultureInfo):
     if culture_info is None:
         culture_info = CultureInfo(Culture.Spanish)
     super().__init__(culture_info)
     self._internal_number_extractor = SpanishNumberExtractor(
         NumberMode.DEFAULT)
     self._internal_number_parser = AgnosticNumberParserFactory.get_parser(
         ParserType.NUMBER, SpanishNumberParserConfiguration(culture_info))
 def __init__(self, culture_info: CultureInfo):
     if culture_info is None:
         culture_info = CultureInfo(Culture.Spanish)
     super().__init__(culture_info)
     self._unit_num_extractor = SpanishNumberExtractor()
     self._build_prefix = SpanishNumericWithUnit.BuildPrefix
     self._build_suffix = SpanishNumericWithUnit.BuildSuffix
     self._compound_unit_connector_regex = RegExpUtility.get_safe_reg_exp(
         SpanishNumericWithUnit.CompoundUnitConnectorRegex)
Exemple #4
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()))