Ejemplo n.º 1
0
        public NumberExtractor(NumberMode mode = NumberMode.Default)
        {
            var builder = ImmutableDictionary.CreateBuilder <Regex, TypeTag>();

            CardinalExtractor cardExtract = null;

            switch (mode)
            {
            case NumberMode.PureNumber:
                cardExtract = new CardinalExtractor(NumbersDefinitions.PlaceHolderPureNumber);
                break;

            case NumberMode.Currency:
                builder.Add(new Regex(NumbersDefinitions.CurrencyRegex, RegexOptions.Singleline),
                            RegexTagGenerator.GenerateRegexTag(Constants.INTEGER_PREFIX, Constants.NUMBER_SUFFIX));
                break;

            case NumberMode.Default:
                break;
            }

            if (cardExtract == null)
            {
                cardExtract = new CardinalExtractor();
            }

            builder.AddRange(cardExtract.Regexes);

            var fracExtract = new FractionExtractor();

            builder.AddRange(fracExtract.Regexes);

            Regexes = builder.ToImmutable();
        }
        public NumberExtractor(NumberMode mode = NumberMode.Default)
        {
            var builder = ImmutableDictionary.CreateBuilder <Regex, string>();

            CardinalExtractor cardExtract = null;

            switch (mode)
            {
            case NumberMode.PureNumber:
                cardExtract = new CardinalExtractor(NumbersDefinitions.PlaceHolderPureNumber);
                break;

            case NumberMode.Currency:
                builder.Add(new Regex(NumbersDefinitions.CurrencyRegex, RegexOptions.Singleline), "IntegerNum");
                break;

            case NumberMode.Default:
                break;
            }

            if (cardExtract == null)
            {
                cardExtract = new CardinalExtractor();
            }

            builder.AddRange(cardExtract.Regexes);

            var fracExtract = new FractionExtractor();

            builder.AddRange(fracExtract.Regexes);

            Regexes = builder.ToImmutable();
        }