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 = 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);

            //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)
        {
            var builder = ImmutableDictionary.CreateBuilder <Regex, string>();

            //Add Cardinal
            CardinalExtractor cardExtract = null;

            switch (mode)
            {
            case NumberMode.PureNumber:
                cardExtract = new CardinalExtractor(@"\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 = new CardinalExtractor();
            }
            builder.AddRange(cardExtract.Regexes);

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

            builder.AddRange(fracExtract.Regexes);

            this.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), RegexTagGenerator.GenerateRegexTag(Constants.FRACTION_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);

            this.Regexes = builder.ToImmutable();
        }
        public static CardinalExtractor GetInstance(string placeholder = NumbersDefinitions.PlaceHolderDefault)
        {
            if (!Instances.ContainsKey(placeholder))
            {
                var instance = new CardinalExtractor(placeholder);
                Instances.TryAdd(placeholder, instance);
            }

            return(Instances[placeholder]);
        }
Exemplo n.º 5
0
        } = Constants.SYS_NUM_CARDINAL;                                                     // "Cardinal";

        public static CardinalExtractor GetInstance(BaseNumberOptionsConfiguration config)
        {
            var extractorKey = config.Placeholder;

            if (!Instances.ContainsKey(extractorKey))
            {
                var instance = new CardinalExtractor(config);
                Instances.TryAdd(extractorKey, instance);
            }

            return(Instances[extractorKey]);
        }