def __init__(self, culture_info: CultureInfo): if culture_info is None: culture_info = CultureInfo(Culture.Chinese) super().__init__(culture_info) self._internal_number_extractor = ChineseNumberExtractor( ChineseNumberExtractorMode.EXTRACT_ALL) self._internal_number_parser = AgnosticNumberParserFactory.get_parser( ParserType.NUMBER, ChineseNumberParserConfiguration(culture_info))
def __init__(self, culture_info: CultureInfo): if culture_info is None: culture_info = CultureInfo(Culture.Chinese) super().__init__(culture_info) self._unit_num_extractor = ChineseNumberExtractor( ChineseNumberExtractorMode.EXTRACT_ALL) self._build_prefix = ChineseNumericWithUnit.BuildPrefix self._build_suffix = ChineseNumericWithUnit.BuildSuffix
def __init__(self, culture_info: CultureInfo): if culture_info is None: culture_info = CultureInfo(Culture.Chinese) super().__init__(culture_info) self._unit_num_extractor = ChineseNumberExtractor(ChineseNumberExtractorMode.EXTRACT_ALL) self._build_prefix = ChineseNumericWithUnit.BuildPrefix self._build_suffix = ChineseNumericWithUnit.BuildSuffix self._compound_unit_connector_regex = RegExpUtility.get_safe_reg_exp(ChineseNumericWithUnit.CompoundUnitConnectorRegex) self._pm_non_unit_regex = RegExpUtility.get_safe_reg_exp(BaseUnits.PmNonUnitRegex)
def __init__(self, culture_info: CultureInfo): if culture_info is None: culture_info = CultureInfo(Culture.Chinese) super().__init__(culture_info) self._internal_number_extractor = ChineseNumberExtractor( ChineseNumberExtractorMode.EXTRACT_ALL) self._internal_number_parser = AgnosticNumberParserFactory.get_parser( ParserType.NUMBER, ChineseNumberParserConfiguration(culture_info)) self.currency_name_to_iso_code_map = ChineseNumericWithUnit.CurrencyNameToIsoCodeMap self.currency_fraction_code_list = ChineseNumericWithUnit.FractionalUnitNameToCodeMap
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()))