Ejemplo n.º 1
0
        protected override void InitializeConfiguration()
        {
            RegisterModel <NumberModel>(
                Culture.English,
                options => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new EnglishNumberParserConfiguration(options)),
                    English.MergedNumberExtractor.GetInstance(NumberMode.PureNumber, options)));

            RegisterModel <OrdinalModel>(
                Culture.English,
                options => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new EnglishNumberParserConfiguration(options)),
                    English.OrdinalExtractor.GetInstance(options)));

            RegisterModel <PercentModel>(
                Culture.English,
                options => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new EnglishNumberParserConfiguration(options)),
                    new English.PercentageExtractor(options)));

            RegisterModel <NumberRangeModel>(
                Culture.English,
                options => new NumberRangeModel(
                    new BaseNumberRangeParser(new EnglishNumberRangeParserConfiguration()),
                    new English.NumberRangeExtractor(options)));

            RegisterModel <NumberModel>(
                Culture.Chinese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration()),
                    new Chinese.NumberExtractor()));

            RegisterModel <OrdinalModel>(
                Culture.Chinese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new ChineseNumberParserConfiguration()),
                    new Chinese.OrdinalExtractor()));

            RegisterModel <PercentModel>(
                Culture.Chinese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new ChineseNumberParserConfiguration()),
                    new Chinese.PercentageExtractor()));

            RegisterModel <NumberRangeModel>(
                Culture.Chinese,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new ChineseNumberRangeParserConfiguration()),
                    new Chinese.NumberRangeExtractor(options)));

            RegisterModel <NumberModel>(
                Culture.Spanish,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new SpanishNumberParserConfiguration()),
                    Spanish.NumberExtractor.GetInstance(NumberMode.PureNumber, options)));

            RegisterModel <OrdinalModel>(
                Culture.Spanish,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new SpanishNumberParserConfiguration()),
                    Spanish.OrdinalExtractor.GetInstance()));

            RegisterModel <PercentModel>(
                Culture.Spanish,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new SpanishNumberParserConfiguration()),
                    new Spanish.PercentageExtractor()));

            RegisterModel <NumberRangeModel>(
                Culture.Spanish,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new SpanishNumberRangeParserConfiguration()),
                    new Spanish.NumberRangeExtractor(options)));

            RegisterModel <NumberModel>(
                Culture.Portuguese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new PortugueseNumberParserConfiguration()),
                    Portuguese.NumberExtractor.GetInstance(NumberMode.PureNumber, options)));

            RegisterModel <OrdinalModel>(
                Culture.Portuguese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new PortugueseNumberParserConfiguration()),
                    Portuguese.OrdinalExtractor.GetInstance()));

            RegisterModel <PercentModel>(
                Culture.Portuguese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new PortugueseNumberParserConfiguration()),
                    new Portuguese.PercentageExtractor()));

            RegisterModel <NumberModel>(
                Culture.French,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new FrenchNumberParserConfiguration()),
                    French.NumberExtractor.GetInstance(NumberMode.PureNumber, options)));

            RegisterModel <OrdinalModel>(
                Culture.French,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new FrenchNumberParserConfiguration()),
                    French.OrdinalExtractor.GetInstance()));

            RegisterModel <PercentModel>(
                Culture.French,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new FrenchNumberParserConfiguration()),
                    new French.PercentageExtractor()));

            RegisterModel <NumberModel>(
                Culture.German,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new GermanNumberParserConfiguration()),
                    German.NumberExtractor.GetInstance(NumberMode.PureNumber)));

            RegisterModel <OrdinalModel>(
                Culture.German,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new GermanNumberParserConfiguration()),
                    German.OrdinalExtractor.GetInstance()));

            RegisterModel <PercentModel>(
                Culture.German,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new GermanNumberParserConfiguration()),
                    new German.PercentageExtractor()));

            RegisterModel <NumberModel>(
                Culture.Italian,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new ItalianNumberParserConfiguration()),
                    Italian.NumberExtractor.GetInstance(NumberMode.PureNumber, options)));

            RegisterModel <OrdinalModel>(
                Culture.Italian,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new ItalianNumberParserConfiguration()),
                    Italian.OrdinalExtractor.GetInstance()));

            RegisterModel <PercentModel>(
                Culture.Italian,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new ItalianNumberParserConfiguration()),
                    new Italian.PercentageExtractor()));

            RegisterModel <NumberRangeModel>(
                Culture.Italian,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new ItalianNumberRangeParserConfiguration()),
                    new Italian.NumberRangeExtractor(options)));

            RegisterModel <NumberModel>(
                Culture.Japanese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new JapaneseNumberParserConfiguration()),
                    new Japanese.NumberExtractor()));

            RegisterModel <OrdinalModel>(
                Culture.Japanese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new JapaneseNumberParserConfiguration()),
                    new Japanese.OrdinalExtractor()));

            RegisterModel <PercentModel>(
                Culture.Japanese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new JapaneseNumberParserConfiguration()),
                    new Japanese.PercentageExtractor()));

            /*
             * RegisterModel<NumberRangeModel>(
             *  Culture.Japanese,
             *  (options) => new NumberRangeModel(
             *      new BaseNumberRangeParser(new JapaneseNumberRangeParserConfiguration()),
             *      new Japanese.NumberRangeExtractor(options)));
             */

            RegisterModel <NumberModel>(
                Culture.Korean,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new KoreanNumberParserConfiguration()),
                    new Korean.NumberExtractor()));

            RegisterModel <NumberModel>(
                Culture.Dutch,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new DutchNumberParserConfiguration()),
                    Dutch.NumberExtractor.GetInstance(NumberMode.PureNumber)));

            RegisterModel <OrdinalModel>(
                Culture.Dutch,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new DutchNumberParserConfiguration()),
                    Dutch.OrdinalExtractor.GetInstance()));

            RegisterModel <PercentModel>(
                Culture.Dutch,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new DutchNumberParserConfiguration()),
                    new Dutch.PercentageExtractor(options)));

            // When registering NumberRangeModel, enable TestNumber_Dutch -> NumberRangeModel tests

            /*
             * RegisterModel<NumberRangeModel>(
             *  Culture.Dutch,
             *  (options) => new NumberRangeModel(
             *      new BaseNumberRangeParser(new DutchNumberRangeParserConfiguration()),
             *      new Dutch.NumberRangeExtractor(options)));
             */
        }
Ejemplo n.º 2
0
        protected override void InitializeConfiguration()
        {
            #region English

            RegisterModel <NumberModel>(
                Culture.English,
                options => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number,
                                                          new EnglishNumberParserConfiguration(options)),
                    English.MergedNumberExtractor.GetInstance(NumberMode.PureNumber, options)));
            RegisterModel <OrdinalModel>(
                Culture.English,
                options => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal,
                                                          new EnglishNumberParserConfiguration(options)),
                    English.OrdinalExtractor.GetInstance()));
            RegisterModel <PercentModel>(
                Culture.English,
                options => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage,
                                                          new EnglishNumberParserConfiguration(options)),
                    new English.PercentageExtractor(options)));
            RegisterModel <NumberRangeModel>(
                Culture.English,
                options => new NumberRangeModel(
                    new BaseNumberRangeParser(new EnglishNumberRangeParserConfiguration()),
                    new English.NumberRangeExtractor()));
            #endregion

            #region Chinese
            RegisterModel <NumberModel>(
                Culture.Chinese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration()),
                    new Chinese.NumberExtractor()));
            RegisterModel <OrdinalModel>(
                Culture.Chinese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new ChineseNumberParserConfiguration()),
                    new Chinese.OrdinalExtractor()));
            RegisterModel <PercentModel>(
                Culture.Chinese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new ChineseNumberParserConfiguration()),
                    new Chinese.PercentageExtractor()));
            RegisterModel <NumberRangeModel>(
                Culture.Chinese,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new ChineseNumberRangeParserConfiguration()),
                    new Chinese.NumberRangeExtractor()));
            #endregion

            #region Spanish
            RegisterModel <NumberModel>(
                Culture.Spanish,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new SpanishNumberParserConfiguration()),
                    new Spanish.NumberExtractor(NumberMode.PureNumber)));
            RegisterModel <OrdinalModel>(
                Culture.Spanish,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new SpanishNumberParserConfiguration()),
                    new Spanish.OrdinalExtractor()));
            RegisterModel <PercentModel>(
                Culture.Spanish,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new SpanishNumberParserConfiguration()),
                    new Spanish.PercentageExtractor()));
            #endregion

            #region Portuguese
            RegisterModel <NumberModel>(
                Culture.Portuguese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new PortugueseNumberParserConfiguration()),
                    new Portuguese.NumberExtractor(NumberMode.PureNumber)));
            RegisterModel <OrdinalModel>(
                Culture.Portuguese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new PortugueseNumberParserConfiguration()),
                    new Portuguese.OrdinalExtractor()));
            RegisterModel <PercentModel>(
                Culture.Portuguese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new PortugueseNumberParserConfiguration()),
                    new Portuguese.PercentageExtractor()));
            #endregion

            #region French
            RegisterModel <NumberModel>(
                Culture.French,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new FrenchNumberParserConfiguration()),
                    new French.NumberExtractor(NumberMode.PureNumber)));
            RegisterModel <OrdinalModel>(
                Culture.French,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new FrenchNumberParserConfiguration()),
                    new French.OrdinalExtractor()));
            RegisterModel <PercentModel>(
                Culture.French,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new FrenchNumberParserConfiguration()),
                    new French.PercentageExtractor()));
            #endregion

            #region German
            RegisterModel <NumberModel>(
                Culture.German,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new GermanNumberParserConfiguration()),
                    German.NumberExtractor.GetInstance(NumberMode.PureNumber)));
            RegisterModel <OrdinalModel>(
                Culture.German,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new GermanNumberParserConfiguration()),
                    German.OrdinalExtractor.GetInstance()));
            RegisterModel <PercentModel>(
                Culture.German,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new GermanNumberParserConfiguration()),
                    new German.PercentageExtractor()));
            #endregion

            #region Japanese
            RegisterModel <NumberModel>(
                Culture.Japanese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new JapaneseNumberParserConfiguration()),
                    new Japanese.NumberExtractor()));
            RegisterModel <OrdinalModel>(
                Culture.Japanese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new JapaneseNumberParserConfiguration()),
                    new Japanese.OrdinalExtractor()));
            RegisterModel <PercentModel>(
                Culture.Japanese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new JapaneseNumberParserConfiguration()),
                    new Japanese.PercentageExtractor()));
            RegisterModel <NumberRangeModel>(
                Culture.Japanese,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new JapaneseNumberRangeParserConfiguration()),
                    new Japanese.NumberRangeExtractor()));
            #endregion
        }
Ejemplo n.º 3
0
        private NumberRecognizer(NumberOptions options)
        {
            RegisterModel(Culture.English, options.ToString(), new Dictionary <Type, IModel>
            {
                [typeof(NumberModel)] = new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new EnglishNumberParserConfiguration()),
                    English.NumberExtractor.GetInstance(NumberMode.PureNumber)),
                [typeof(OrdinalModel)] = new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new EnglishNumberParserConfiguration()),
                    English.OrdinalExtractor.GetInstance()),
                [typeof(PercentModel)] = new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new EnglishNumberParserConfiguration()),
                    new English.PercentageExtractor())
            });

            RegisterModel(Culture.Chinese, options.ToString(), new Dictionary <Type, IModel>
            {
                [typeof(NumberModel)] = new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration()),
                    new Chinese.NumberExtractor()),
                [typeof(OrdinalModel)] = new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new ChineseNumberParserConfiguration()),
                    new Chinese.OrdinalExtractor()),
                [typeof(PercentModel)] = new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new ChineseNumberParserConfiguration()),
                    new Chinese.PercentageExtractor())
            });

            RegisterModel(Culture.Spanish, options.ToString(), new Dictionary <Type, IModel>
            {
                [typeof(NumberModel)] = new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new SpanishNumberParserConfiguration()),
                    new Spanish.NumberExtractor(NumberMode.PureNumber)),
                [typeof(OrdinalModel)] = new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new SpanishNumberParserConfiguration()),
                    new Spanish.OrdinalExtractor()),
                [typeof(PercentModel)] = new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new SpanishNumberParserConfiguration()),
                    new Spanish.PercentageExtractor())
            });

            RegisterModel(Culture.Portuguese, options.ToString(), new Dictionary <Type, IModel>
            {
                [typeof(NumberModel)] = new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new PortugueseNumberParserConfiguration()),
                    new Portuguese.NumberExtractor(NumberMode.PureNumber)),
                [typeof(OrdinalModel)] = new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new PortugueseNumberParserConfiguration()),
                    new Portuguese.OrdinalExtractor()),
                [typeof(PercentModel)] = new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new PortugueseNumberParserConfiguration()),
                    new Portuguese.PercentageExtractor())
            });

            RegisterModel(Culture.French, options.ToString(), new Dictionary <Type, IModel>
            {
                [typeof(NumberModel)] = new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new FrenchNumberParserConfiguration()),
                    new French.NumberExtractor(NumberMode.PureNumber)),
                [typeof(OrdinalModel)] = new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new FrenchNumberParserConfiguration()),
                    new French.OrdinalExtractor()),
                [typeof(PercentModel)] = new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new FrenchNumberParserConfiguration()),
                    new French.PercentageExtractor())
            });

            RegisterModel(Culture.German, options.ToString(), new Dictionary <Type, IModel>
            {
                [typeof(NumberModel)] = new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new GermanNumberParserConfiguration()),
                    German.NumberExtractor.GetInstance(NumberMode.PureNumber)),
                [typeof(OrdinalModel)] = new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new GermanNumberParserConfiguration()),
                    German.OrdinalExtractor.GetInstance()),
                [typeof(PercentModel)] = new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new GermanNumberParserConfiguration()),
                    new German.PercentageExtractor())
            });
        }
Ejemplo n.º 4
0
        protected override void InitializeConfiguration()
        {
            RegisterModel <NumberModel>(
                Culture.Arabic,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new ArabicNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Arabic, options))),
                    Arabic.NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Arabic, options, NumberMode.PureNumber))));

            RegisterModel <OrdinalModel>(
                Culture.Arabic,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new ArabicNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Arabic, options))),
                    Arabic.OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Arabic, options))));

            RegisterModel <PercentModel>(
                Culture.Arabic,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new ArabicNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Arabic, options))),
                    new Arabic.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.Arabic, options))));

            RegisterModel <NumberRangeModel>(
                Culture.Arabic,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new ArabicNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Arabic, options))),
                    new Arabic.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Arabic, options))));

            RegisterModel <NumberModel>(
                Culture.English,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new EnglishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.English, options))),
                    English.MergedNumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.English, options, NumberMode.PureNumber))));

            RegisterModel <OrdinalModel>(
                Culture.English,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new EnglishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.English, options))),
                    English.OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.English, options))));

            RegisterModel <PercentModel>(
                Culture.English,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new EnglishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.English, options))),
                    new English.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.English, options))));

            RegisterModel <NumberRangeModel>(
                Culture.English,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new EnglishNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.English, options))),
                    new English.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.English, options))));

            RegisterModel <NumberModel>(
                Culture.Chinese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Chinese, options))),
                    new Chinese.NumberExtractor(new BaseNumberOptionsConfiguration(Culture.Chinese, options))));

            RegisterModel <OrdinalModel>(
                Culture.Chinese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new ChineseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Chinese, options))),
                    new Chinese.OrdinalExtractor(new BaseNumberOptionsConfiguration(Culture.Chinese, options))));

            RegisterModel <PercentModel>(
                Culture.Chinese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new ChineseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Chinese, options))),
                    new Chinese.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.Chinese, options))));

            RegisterModel <NumberRangeModel>(
                Culture.Chinese,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new ChineseNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Chinese, options))),
                    new Chinese.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Chinese, options))));

            RegisterModel <NumberModel>(
                Culture.Spanish,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new SpanishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Spanish, options))),
                    Spanish.NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Spanish, options, NumberMode.PureNumber))));

            RegisterModel <OrdinalModel>(
                Culture.Spanish,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new SpanishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Spanish, options))),
                    Spanish.OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Spanish, options))));

            RegisterModel <PercentModel>(
                Culture.Spanish,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new SpanishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Spanish, options))),
                    new Spanish.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.Spanish, options))));

            RegisterModel <NumberRangeModel>(
                Culture.Spanish,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new SpanishNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Spanish, options))),
                    new Spanish.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Spanish, options))));

            RegisterModel <NumberModel>(
                Culture.Portuguese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new PortugueseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Portuguese, options))),
                    Portuguese.NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Portuguese, options, NumberMode.PureNumber))));

            RegisterModel <OrdinalModel>(
                Culture.Portuguese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new PortugueseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Portuguese, options))),
                    Portuguese.OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Portuguese, options))));

            RegisterModel <PercentModel>(
                Culture.Portuguese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new PortugueseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Portuguese, options))),
                    new Portuguese.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.Portuguese, options))));

            /*
             * RegisterModel<NumberRangeModel>(
             *  Culture.Portuguese,
             *  (options) => new NumberRangeModel(
             *      new BaseNumberRangeParser(new PortugueseRangeParserConfiguration(
             *                                    new BaseNumberOptionsConfiguration(Culture.Portuguese, options))),
             *      new Portuguese.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Portuguese, options))));
             */

            RegisterModel <NumberModel>(
                Culture.French,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new FrenchNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.French, options))),
                    French.NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.French, options, NumberMode.PureNumber))));

            RegisterModel <OrdinalModel>(
                Culture.French,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new FrenchNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.French, options))),
                    French.OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.French, options))));

            RegisterModel <PercentModel>(
                Culture.French,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new FrenchNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.French, options))),
                    new French.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.French, options))));

            RegisterModel <NumberRangeModel>(
                Culture.French,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new FrenchNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.French, options))),
                    new French.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.French, options))));

            RegisterModel <NumberModel>(
                Culture.German,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new GermanNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.German, options))),
                    German.NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.German, options, NumberMode.PureNumber))));

            RegisterModel <OrdinalModel>(
                Culture.German,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new GermanNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.German, options))),
                    German.OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.German, options))));

            RegisterModel <PercentModel>(
                Culture.German,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new GermanNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.German, options))),
                    new German.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.German, options))));

            RegisterModel <NumberRangeModel>(
                Culture.German,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new GermanNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.German, options))),
                    new German.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.German, options))));

            RegisterModel <NumberModel>(
                Culture.Italian,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new ItalianNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Italian, options))),
                    Italian.NumberExtractor.GetInstance(NumberMode.PureNumber, options)));

            RegisterModel <OrdinalModel>(
                Culture.Italian,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new ItalianNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Italian, options))),
                    Italian.OrdinalExtractor.GetInstance()));

            RegisterModel <PercentModel>(
                Culture.Italian,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new ItalianNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Italian, options))),
                    new Italian.PercentageExtractor()));

            RegisterModel <NumberRangeModel>(
                Culture.Italian,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new ItalianNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Italian, options))),
                    new Italian.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Italian, options))));

            RegisterModel <NumberModel>(
                Culture.Dutch,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new DutchNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Dutch, options))),
                    Dutch.NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Dutch, options, NumberMode.PureNumber))));

            RegisterModel <OrdinalModel>(
                Culture.Dutch,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new DutchNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Dutch, options))),
                    Dutch.OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Dutch, options))));

            RegisterModel <PercentModel>(
                Culture.Dutch,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new DutchNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Dutch, options))),
                    new Dutch.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.Dutch, options))));

            RegisterModel <NumberRangeModel>(
                Culture.Dutch,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new DutchNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Dutch, options))),
                    new Dutch.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Dutch, options))));

            RegisterModel <NumberModel>(
                Culture.Japanese,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new JapaneseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Japanese, options))),
                    new Japanese.NumberExtractor()));

            RegisterModel <OrdinalModel>(
                Culture.Japanese,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new JapaneseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Japanese, options))),
                    new Japanese.OrdinalExtractor()));

            RegisterModel <PercentModel>(
                Culture.Japanese,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new JapaneseNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Japanese, options))),
                    new Japanese.PercentageExtractor()));

            RegisterModel <NumberRangeModel>(
                Culture.Japanese,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new JapaneseNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Japanese, options))),
                    new Japanese.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Japanese, options))));

            RegisterModel <NumberModel>(
                Culture.Korean,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new KoreanNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Korean, options))),
                    new Korean.NumberExtractor()));

            RegisterModel <OrdinalModel>(
                Culture.Korean,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new KoreanNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Korean, options))),
                    new Korean.OrdinalExtractor()));

            RegisterModel <PercentModel>(
                Culture.Korean,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new KoreanNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Korean, options))),
                    new Korean.PercentageExtractor()));

            RegisterModel <NumberRangeModel>(
                Culture.Korean,
                (options) => new NumberRangeModel(
                    new BaseNumberRangeParser(new KoreanNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Korean, options))),
                    new Korean.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Korean, options))));

            RegisterModel <NumberModel>(
                Culture.Turkish,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new TurkishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Turkish, options))),
                    Turkish.NumberExtractor.GetInstance(NumberMode.PureNumber)));

            RegisterModel <OrdinalModel>(
                Culture.Turkish,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new TurkishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Turkish, options))),
                    Turkish.OrdinalExtractor.GetInstance()));

            RegisterModel <PercentModel>(
                Culture.Turkish,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new TurkishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Turkish, options))),
                    new Turkish.PercentageExtractor(options)));

            RegisterModel <NumberRangeModel>(
                Culture.Turkish,
                options => new NumberRangeModel(
                    new BaseNumberRangeParser(new TurkishNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Turkish, options))),
                    new Turkish.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Turkish, options))));

            RegisterModel <NumberModel>(
                Culture.Hindi,
                options => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new HindiNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Hindi, options))),
                    Hindi.MergedNumberExtractor.GetInstance(NumberMode.PureNumber, options)));

            RegisterModel <OrdinalModel>(
                Culture.Hindi,
                options => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new HindiNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Hindi, options))),
                    Hindi.OrdinalExtractor.GetInstance(options)));

            RegisterModel <PercentModel>(
                Culture.Hindi,
                options => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new HindiNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Hindi, options))),
                    new Hindi.PercentageExtractor(options)));

            RegisterModel <NumberRangeModel>(
                Culture.Hindi,
                options => new NumberRangeModel(
                    new BaseNumberRangeParser(new HindiNumberRangeParserConfiguration(
                                                  new BaseNumberOptionsConfiguration(Culture.Hindi, options))),
                    new Hindi.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Hindi, options))));

            RegisterModel <NumberModel>(
                Culture.Swedish,
                (options) => new NumberModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new SwedishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Swedish, options))),
                    Swedish.NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Swedish, options, NumberMode.PureNumber))));

            RegisterModel <OrdinalModel>(
                Culture.Swedish,
                (options) => new OrdinalModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new SwedishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Swedish, options))),
                    Swedish.OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(Culture.Swedish, options))));

            RegisterModel <PercentModel>(
                Culture.Swedish,
                (options) => new PercentModel(
                    AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new SwedishNumberParserConfiguration(
                                                              new BaseNumberOptionsConfiguration(Culture.Swedish, options))),
                    new Swedish.PercentageExtractor(new BaseNumberOptionsConfiguration(Culture.Swedish, options))));

            // RegisterModel<NumberRangeModel>(
            //    Culture.Swedish,
            //    (options) => new NumberRangeModel(
            //        new BaseNumberRangeParser(new SwedishNumberRangeParserConfiguration(
            //                                        new BaseNumberOptionsConfiguration(Culture.Swedish, options))),
            //        new Swedish.NumberRangeExtractor(new BaseNumberOptionsConfiguration(Culture.Swedish, options))));
        }
Ejemplo n.º 5
0
 static NumberRecognizer()
 {
     ModelInstances = new Dictionary <string, Dictionary <Type, IModel> >(StringComparer.InvariantCultureIgnoreCase)
     {
         {
             Culture.English, new Dictionary <Type, IModel>
             {
                 [typeof(NumberModel)] = new NumberModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new EnglishNumberParserConfiguration()),
                     new English.NumberExtractor(NumberMode.PureNumber)),
                 [typeof(OrdinalModel)] = new OrdinalModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new EnglishNumberParserConfiguration()),
                     new English.OrdinalExtractor()),
                 [typeof(PercentModel)] = new PercentModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new EnglishNumberParserConfiguration()),
                     new English.PercentageExtractor())
             }
         },
         {
             Culture.Chinese, new Dictionary <Type, IModel>
             {
                 [typeof(NumberModel)] = new NumberModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new ChineseNumberParserConfiguration()),
                     new Chinese.NumberExtractor()),
                 [typeof(OrdinalModel)] = new OrdinalModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new ChineseNumberParserConfiguration()),
                     new Chinese.OrdinalExtractor()),
                 [typeof(PercentModel)] = new PercentModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new ChineseNumberParserConfiguration()),
                     new Chinese.PercentageExtractor())
             }
         },
         {
             Culture.Spanish, new Dictionary <Type, IModel>
             {
                 [typeof(NumberModel)] = new NumberModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number, new SpanishNumberParserConfiguration()),
                     new Spanish.NumberExtractor(NumberMode.PureNumber)),
                 [typeof(OrdinalModel)] = new OrdinalModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal, new SpanishNumberParserConfiguration()),
                     new Spanish.OrdinalExtractor()),
                 [typeof(PercentModel)] = new PercentModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage, new SpanishNumberParserConfiguration()),
                     new Spanish.PercentageExtractor())
             }
         },
         {
             Culture.French, new Dictionary <Type, IModel>
             {
                 [typeof(NumberModel)] = new NumberModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Number,
                                                           new FrenchNumberParserConfiguration()),
                     new Spanish.NumberExtractor(NumberMode.PureNumber)),
                 [typeof(OrdinalModel)] = new OrdinalModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Ordinal,
                                                           new FrenchNumberParserConfiguration()),
                     new Spanish.OrdinalExtractor()),
                 [typeof(PercentModel)] = new PercentModel(
                     AgnosticNumberParserFactory.GetParser(AgnosticNumberParserType.Percentage,
                                                           new FrenchNumberParserConfiguration()),
                     new Spanish.PercentageExtractor())
             }
         }
     };
 }