Exemplo n.º 1
0
        } = Constants.SYS_NUM;                                                     // "Number";

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

            //Add Cardinal
            CardinalExtractor cardExtract = null;

            switch (mode)
            {
            case NumberMode.PureNumber:
                cardExtract = CardinalExtractor.GetInstance(@"\b");
                break;

            case NumberMode.Currency:
                builder.Add(new Regex(@"(((?<=\W|^)-\s*)|(?<=\b))\d+\s*(B|b|m|t|g)(?=\b)", RegexOptions.Singleline),
                            "IntegerNum");
                break;

            case NumberMode.Default:
                break;
            }

            if (cardExtract == null)
            {
                cardExtract = CardinalExtractor.GetInstance();
            }
            builder.AddRange(cardExtract.Regexes);

            //Add Fraction
            var fracExtract = new FractionExtractor();

            builder.AddRange(fracExtract.Regexes);

            this.Regexes = builder.ToImmutable();
        }
Exemplo n.º 2
0
        } = Constants.SYS_NUM;                                                     // "Number";

        public NumberExtractor(NumberMode mode = NumberMode.Default, NumberOptions options = NumberOptions.None)
        {
            var builder = ImmutableDictionary.CreateBuilder <Regex, TypeTag>();

            //Add Cardinal
            CardinalExtractor cardExtract = null;

            switch (mode)
            {
            case NumberMode.PureNumber:
                cardExtract = CardinalExtractor.GetInstance(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 = CardinalExtractor.GetInstance();
            }

            builder.AddRange(cardExtract.Regexes);

            //Add Fraction
            var fracExtract = new FractionExtractor();

            builder.AddRange(fracExtract.Regexes);

            Regexes = builder.ToImmutable();
        }
Exemplo n.º 3
0
        } = Constants.SYS_NUM;                                                     // "Number";

        public NumberExtractor(NumberMode mode = NumberMode.Default, NumberOptions options = NumberOptions.None)
        {
            var builder = ImmutableDictionary.CreateBuilder <Regex, string>();

            //Add Cardinal
            CardinalExtractor cardExtract = null;

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

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

            case NumberMode.Default:
                break;
            }

            if (cardExtract == null)
            {
                cardExtract = CardinalExtractor.GetInstance();
            }

            builder.AddRange(cardExtract.Regexes);

            //Add Fraction
            var fracExtract = new FractionExtractor();

            builder.AddRange(fracExtract.Regexes);

            this.Regexes = builder.ToImmutable();
        }