예제 #1
0
        public DutchNumberParserConfiguration(INumberOptionsConfiguration config)
        {
            this.Config         = config;
            this.LanguageMarker = NumbersDefinitions.LangMarker;
            this.CultureInfo    = new CultureInfo(config.Culture);

            this.IsCompoundNumberLanguage       = NumbersDefinitions.CompoundNumberLanguage;
            this.IsMultiDecimalSeparatorCulture = NumbersDefinitions.MultiDecimalSeparatorCulture;

            this.DecimalSeparatorChar    = NumbersDefinitions.DecimalSeparatorChar;
            this.FractionMarkerToken     = NumbersDefinitions.FractionMarkerToken;
            this.NonDecimalSeparatorChar = NumbersDefinitions.NonDecimalSeparatorChar;
            this.HalfADozenText          = NumbersDefinitions.HalfADozenText;
            this.WordSeparatorToken      = NumbersDefinitions.WordSeparatorToken;

            this.WrittenDecimalSeparatorTexts  = NumbersDefinitions.WrittenDecimalSeparatorTexts;
            this.WrittenGroupSeparatorTexts    = NumbersDefinitions.WrittenGroupSeparatorTexts;
            this.WrittenIntegerSeparatorTexts  = NumbersDefinitions.WrittenIntegerSeparatorTexts;
            this.WrittenFractionSeparatorTexts = NumbersDefinitions.WrittenFractionSeparatorTexts;

            this.CardinalNumberMap              = NumbersDefinitions.CardinalNumberMap.ToImmutableDictionary();
            this.OrdinalNumberMap               = NumbersDefinitions.OrdinalNumberMap.ToImmutableDictionary();
            this.RelativeReferenceOffsetMap     = NumbersDefinitions.RelativeReferenceOffsetMap.ToImmutableDictionary();
            this.RelativeReferenceRelativeToMap = NumbersDefinitions.RelativeReferenceRelativeToMap.ToImmutableDictionary();
            this.RoundNumberMap = NumbersDefinitions.RoundNumberMap.ToImmutableDictionary();

            // @TODO Change init to follow design in other languages
            this.HalfADozenRegex          = new Regex(NumbersDefinitions.HalfADozenRegex, RegexFlags);
            this.DigitalNumberRegex       = new Regex(NumbersDefinitions.DigitalNumberRegex, RegexFlags);
            this.NegativeNumberSignRegex  = new Regex(NumbersDefinitions.NegativeNumberSignRegex, RegexFlags);
            this.FractionPrepositionRegex = new Regex(NumbersDefinitions.FractionPrepositionRegex, RegexFlags);
            this.RoundMultiplierRegex     = new Regex(NumbersDefinitions.RoundMultiplierRegex, RegexFlags);
        }
        public SpanishNumberParserConfiguration(INumberOptionsConfiguration config)
        {
            this.Config         = config;
            this.LanguageMarker = NumbersDefinitions.LangMarker;
            this.CultureInfo    = new CultureInfo(config.Culture);

            this.IsCompoundNumberLanguage       = NumbersDefinitions.CompoundNumberLanguage;
            this.IsMultiDecimalSeparatorCulture = NumbersDefinitions.MultiDecimalSeparatorCulture;

            this.DecimalSeparatorChar    = NumbersDefinitions.DecimalSeparatorChar;
            this.FractionMarkerToken     = NumbersDefinitions.FractionMarkerToken;
            this.NonDecimalSeparatorChar = NumbersDefinitions.NonDecimalSeparatorChar;
            this.HalfADozenText          = NumbersDefinitions.HalfADozenText;
            this.WordSeparatorToken      = NumbersDefinitions.WordSeparatorToken;

            this.WrittenDecimalSeparatorTexts  = NumbersDefinitions.WrittenDecimalSeparatorTexts;
            this.WrittenGroupSeparatorTexts    = NumbersDefinitions.WrittenGroupSeparatorTexts;
            this.WrittenIntegerSeparatorTexts  = NumbersDefinitions.WrittenIntegerSeparatorTexts;
            this.WrittenFractionSeparatorTexts = NumbersDefinitions.WrittenFractionSeparatorTexts;

            this.CardinalNumberMap = NumbersDefinitions.CardinalNumberMap.ToImmutableDictionary();
            this.OrdinalNumberMap  = NumberMapGenerator.InitOrdinalNumberMap(
                NumbersDefinitions.OrdinalNumberMap,
                NumbersDefinitions.PrefixCardinalMap,
                NumbersDefinitions.SuffixOrdinalMap);

            this.RelativeReferenceOffsetMap     = NumbersDefinitions.RelativeReferenceOffsetMap.ToImmutableDictionary();
            this.RelativeReferenceRelativeToMap = NumbersDefinitions.RelativeReferenceRelativeToMap.ToImmutableDictionary();
            this.RoundNumberMap = NumbersDefinitions.RoundNumberMap.ToImmutableDictionary();

            this.HalfADozenRegex          = new Regex(NumbersDefinitions.HalfADozenRegex, RegexFlags);
            this.DigitalNumberRegex       = new Regex(NumbersDefinitions.DigitalNumberRegex, RegexFlags);
            this.NegativeNumberSignRegex  = new Regex(NumbersDefinitions.NegativeNumberSignRegex, RegexFlags);
            this.FractionPrepositionRegex = new Regex(NumbersDefinitions.FractionPrepositionRegex, RegexFlags);
        }
        public HindiNumberParserConfiguration(INumberOptionsConfiguration config)
        {
            this.Config         = config;
            this.LanguageMarker = NumbersDefinitions.LangMarker;
            this.CultureInfo    = new CultureInfo(config.Culture);

            this.IsCompoundNumberLanguage       = NumbersDefinitions.CompoundNumberLanguage;
            this.IsMultiDecimalSeparatorCulture = NumbersDefinitions.MultiDecimalSeparatorCulture;

            this.DecimalSeparatorChar    = NumbersDefinitions.DecimalSeparatorChar;
            this.FractionMarkerToken     = NumbersDefinitions.FractionMarkerToken;
            this.NonDecimalSeparatorChar = NumbersDefinitions.NonDecimalSeparatorChar;
            this.HalfADozenText          = NumbersDefinitions.HalfADozenText;
            this.WordSeparatorToken      = NumbersDefinitions.WordSeparatorToken;

            this.WrittenDecimalSeparatorTexts  = NumbersDefinitions.WrittenDecimalSeparatorTexts;
            this.WrittenGroupSeparatorTexts    = NumbersDefinitions.WrittenGroupSeparatorTexts;
            this.WrittenIntegerSeparatorTexts  = NumbersDefinitions.WrittenIntegerSeparatorTexts;
            this.WrittenFractionSeparatorTexts = NumbersDefinitions.WrittenFractionSeparatorTexts;

            this.CardinalNumberMap              = NumbersDefinitions.CardinalNumberMap.ToImmutableDictionary();
            this.OrdinalNumberMap               = NumbersDefinitions.OrdinalNumberMap.ToImmutableDictionary();
            this.DecimalUnitsMap                = NumbersDefinitions.DecimalUnitsMap.ToImmutableDictionary();
            this.RelativeReferenceOffsetMap     = NumbersDefinitions.RelativeReferenceOffsetMap.ToImmutableDictionary();
            this.RelativeReferenceRelativeToMap = NumbersDefinitions.RelativeReferenceRelativeToMap.ToImmutableDictionary();
            this.RoundNumberMap = NumbersDefinitions.RoundNumberMap.ToImmutableDictionary();
            this.ZeroToNineMap  = NumbersDefinitions.ZeroToNineMap.ToImmutableDictionary();

            this.AdditionTermsRegex              = RegexCache.Get(NumbersDefinitions.AdditionTermsRegex, RegexFlags);
            this.HalfADozenRegex                 = RegexCache.Get(NumbersDefinitions.HalfADozenRegex, RegexFlags);
            this.DigitalNumberRegex              = RegexCache.Get(NumbersDefinitions.DigitalNumberRegex, RegexFlags);
            this.NegativeNumberSignRegex         = RegexCache.Get(NumbersDefinitions.NegativeNumberSignRegex, RegexFlags);
            this.FractionPrepositionRegex        = RegexCache.Get(NumbersDefinitions.FractionPrepositionRegex, RegexFlags);
            this.FractionPrepositionInverseRegex = RegexCache.Get(NumbersDefinitions.FractionPrepositionInverseRegex, RegexFlags);
        }
 public BaseNumberOptionsConfiguration(INumberOptionsConfiguration config)
 {
     Culture     = config.Culture;
     Options     = config.Options;
     Mode        = config.Mode;
     Placeholder = config.Placeholder;
 }
 protected BaseNumberRangeExtractor(BaseNumberExtractor numberExtractor, BaseNumberExtractor ordinalExtractor, BaseNumberParser numberParser,
                                    INumberOptionsConfiguration config)
 {
     this.numberExtractor  = numberExtractor;
     this.ordinalExtractor = ordinalExtractor;
     this.numberParser     = numberParser;
     Config = config;
 }
        public TurkishNumberRangeParserConfiguration(INumberOptionsConfiguration config)
        {
            CultureInfo = new CultureInfo(config.Culture);

            NumberExtractor  = Turkish.NumberExtractor.GetInstance();
            OrdinalExtractor = Turkish.OrdinalExtractor.GetInstance();
            NumberParser     = new BaseNumberParser(new TurkishNumberParserConfiguration(config));
            MoreOrEqual      = new Regex(NumbersDefinitions.MoreOrEqual, RegexFlags);
            LessOrEqual      = new Regex(NumbersDefinitions.LessOrEqual, RegexFlags);
        }
        public ChineseNumberParserConfiguration(INumberOptionsConfiguration config)
        {
            this.LanguageMarker = NumbersDefinitions.LangMarker;
            this.CultureInfo    = new CultureInfo(config.Culture);
            this.Config         = config;

            this.IsCompoundNumberLanguage       = NumbersDefinitions.CompoundNumberLanguage;
            this.IsMultiDecimalSeparatorCulture = NumbersDefinitions.MultiDecimalSeparatorCulture;

            this.DecimalSeparatorChar    = NumbersDefinitions.DecimalSeparatorChar;
            this.FractionMarkerToken     = NumbersDefinitions.FractionMarkerToken;
            this.NonDecimalSeparatorChar = NumbersDefinitions.NonDecimalSeparatorChar;
            this.HalfADozenText          = NumbersDefinitions.HalfADozenText;
            this.WordSeparatorToken      = NumbersDefinitions.WordSeparatorToken;
            this.ZeroChar = NumbersDefinitions.ZeroChar;
            this.PairChar = NumbersDefinitions.PairChar;

            this.WrittenDecimalSeparatorTexts  = Enumerable.Empty <string>();
            this.WrittenGroupSeparatorTexts    = Enumerable.Empty <string>();
            this.WrittenIntegerSeparatorTexts  = Enumerable.Empty <string>();
            this.WrittenFractionSeparatorTexts = Enumerable.Empty <string>();

            this.CardinalNumberMap              = new Dictionary <string, long>().ToImmutableDictionary();
            this.OrdinalNumberMap               = new Dictionary <string, long>().ToImmutableDictionary();
            this.RelativeReferenceOffsetMap     = NumbersDefinitions.RelativeReferenceOffsetMap.ToImmutableDictionary();
            this.RelativeReferenceRelativeToMap = NumbersDefinitions.RelativeReferenceRelativeToMap.ToImmutableDictionary();
            this.RoundNumberMap     = NumbersDefinitions.RoundNumberMap.ToImmutableDictionary();
            this.ZeroToNineMap      = NumbersDefinitions.ZeroToNineMap.ToImmutableDictionary();
            this.RoundNumberMapChar = NumbersDefinitions.RoundNumberMapChar.ToImmutableDictionary();
            this.FullToHalfMap      = NumbersDefinitions.FullToHalfMap.ToImmutableDictionary();
            this.TratoSimMap        = NumbersDefinitions.TratoSimMap.ToImmutableDictionary();
            this.UnitMap            = NumbersDefinitions.UnitMap.OrderBy(o => o.Key.Length).ToImmutableDictionary(o => o.Key, p => p.Value);
            this.RoundDirectList    = NumbersDefinitions.RoundDirectList.ToImmutableList();
            this.TenChars           = NumbersDefinitions.TenChars.ToImmutableList();

            this.HalfADozenRegex = null;

            // @TODO Change init to follow design in other languages
            this.DigitalNumberRegex      = RegexCache.Get(NumbersDefinitions.DigitalNumberRegex, RegexFlags);
            this.DigitNumRegex           = RegexCache.Get(NumbersDefinitions.DigitNumRegex, RegexFlags);
            this.DozenRegex              = RegexCache.Get(NumbersDefinitions.DozenRegex, RegexFlags);
            this.PercentageRegex         = RegexCache.Get(NumbersDefinitions.PercentageRegex, RegexFlags);
            this.DoubleAndRoundRegex     = RegexCache.Get(NumbersDefinitions.DoubleAndRoundRegex, RegexFlags);
            this.FracSplitRegex          = RegexCache.Get(NumbersDefinitions.FracSplitRegex, RegexFlags);
            this.NegativeNumberSignRegex = RegexCache.Get(NumbersDefinitions.NegativeNumberSignRegex, RegexFlags);
            this.PointRegex              = RegexCache.Get(NumbersDefinitions.PointRegex, RegexFlags);
            this.SpeGetNumberRegex       = RegexCache.Get(NumbersDefinitions.SpeGetNumberRegex, RegexFlags);
            this.PairRegex = RegexCache.Get(NumbersDefinitions.PairRegex, RegexFlags);
            this.RoundNumberIntegerRegex  = RegexCache.Get(NumbersDefinitions.RoundNumberIntegerRegex, RegexFlags);
            this.PercentageNumRegex       = RegexCache.Get(NumbersDefinitions.PercentageNumRegex, RegexFlags);
            this.FractionPrepositionRegex = null;
        }
        public ChineseNumberRangeParserConfiguration(INumberOptionsConfiguration config)
        {
            CultureInfo = new CultureInfo(config.Culture);

            NumberExtractor  = new NumberExtractor();
            OrdinalExtractor = new OrdinalExtractor();
            NumberParser     = new BaseCJKNumberParser(new ChineseNumberParserConfiguration(config));

            MoreOrEqual         = new Regex(NumbersDefinitions.MoreOrEqual, RegexFlags);
            LessOrEqual         = new Regex(NumbersDefinitions.LessOrEqual, RegexFlags);
            MoreOrEqualSuffix   = new Regex(NumbersDefinitions.MoreOrEqualSuffix, RegexFlags);
            LessOrEqualSuffix   = new Regex(NumbersDefinitions.LessOrEqualSuffix, RegexFlags);
            MoreOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags);
            LessOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags);
        }
예제 #9
0
        public TurkishNumberRangeParserConfiguration(INumberOptionsConfiguration config)
        {
            CultureInfo = new CultureInfo(config.Culture);

            NumberExtractor  = Turkish.NumberExtractor.GetInstance(NumberMode.Default, config.Options);
            OrdinalExtractor = Turkish.OrdinalExtractor.GetInstance(config.Options);
            NumberParser     = new BaseNumberParser(new TurkishNumberParserConfiguration(config));

            MoreOrEqual         = new Regex(NumbersDefinitions.MoreOrEqual, RegexFlags);
            LessOrEqual         = new Regex(NumbersDefinitions.LessOrEqual, RegexFlags);
            MoreOrEqualSuffix   = new Regex(NumbersDefinitions.MoreOrEqualSuffix, RegexFlags);
            LessOrEqualSuffix   = new Regex(NumbersDefinitions.LessOrEqualSuffix, RegexFlags);
            MoreOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags);
            LessOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags);
        }
예제 #10
0
        public ItalianNumberRangeParserConfiguration(INumberOptionsConfiguration config)
        {
            CultureInfo = new CultureInfo(config.Culture);

            NumberExtractor  = Italian.NumberExtractor.GetInstance();
            OrdinalExtractor = Italian.OrdinalExtractor.GetInstance();

            NumberParser = new BaseNumberParser(new ItalianNumberParserConfiguration(config));

            MoreOrEqual         = RegexCache.Get(NumbersDefinitions.MoreOrEqual, RegexFlags);
            LessOrEqual         = RegexCache.Get(NumbersDefinitions.LessOrEqual, RegexFlags);
            MoreOrEqualSuffix   = RegexCache.Get(NumbersDefinitions.MoreOrEqualSuffix, RegexFlags);
            LessOrEqualSuffix   = RegexCache.Get(NumbersDefinitions.LessOrEqualSuffix, RegexFlags);
            MoreOrEqualSeparate = RegexCache.Get(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags);
            LessOrEqualSeparate = RegexCache.Get(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags);
        }
        public GermanNumberRangeParserConfiguration(INumberOptionsConfiguration config)
        {
            CultureInfo = new CultureInfo(config.Culture);

            var numConfig = new BaseNumberOptionsConfiguration(config.Culture, config.Options);

            NumberExtractor  = German.NumberExtractor.GetInstance(numConfig);
            OrdinalExtractor = German.OrdinalExtractor.GetInstance(numConfig);
            NumberParser     = new BaseNumberParser(new GermanNumberParserConfiguration(config));

            MoreOrEqual         = new Regex(NumbersDefinitions.MoreOrEqual, RegexFlags);
            LessOrEqual         = new Regex(NumbersDefinitions.LessOrEqual, RegexFlags);
            MoreOrEqualSuffix   = new Regex(NumbersDefinitions.MoreOrEqualSuffix, RegexFlags);
            LessOrEqualSuffix   = new Regex(NumbersDefinitions.LessOrEqualSuffix, RegexFlags);
            MoreOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags);
            LessOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags);
        }
        public DutchNumberRangeParserConfiguration(INumberOptionsConfiguration config)
        {
            CultureInfo = new CultureInfo(config.Culture);

            NumberExtractor  = Dutch.NumberExtractor.GetInstance();
            OrdinalExtractor = Dutch.OrdinalExtractor.GetInstance();

            // @TODO Change init to follow design in other languages
            NumberParser = new BaseNumberParser(new DutchNumberParserConfiguration(config));

            MoreOrEqual         = new Regex(NumbersDefinitions.MoreOrEqual, RegexFlags);
            LessOrEqual         = new Regex(NumbersDefinitions.LessOrEqual, RegexFlags);
            MoreOrEqualSuffix   = new Regex(NumbersDefinitions.MoreOrEqualSuffix, RegexFlags);
            LessOrEqualSuffix   = new Regex(NumbersDefinitions.LessOrEqualSuffix, RegexFlags);
            MoreOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags);
            LessOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags);
        }
        public EnglishNumberParserConfiguration(INumberOptionsConfiguration config)
        {
            this.Config         = config;
            this.LanguageMarker = NumbersDefinitions.LangMarker;

            // @TODO Temporary workaround
            var culture = config.Culture;

            if (culture.IndexOf("*", StringComparison.Ordinal) != -1)
            {
                culture = config.Culture.Replace("*", "us");
            }

            this.CultureInfo = new CultureInfo(culture);

            this.IsCompoundNumberLanguage       = NumbersDefinitions.CompoundNumberLanguage;
            this.IsMultiDecimalSeparatorCulture = NumbersDefinitions.MultiDecimalSeparatorCulture;

            this.DecimalSeparatorChar    = NumbersDefinitions.DecimalSeparatorChar;
            this.FractionMarkerToken     = NumbersDefinitions.FractionMarkerToken;
            this.NonDecimalSeparatorChar = NumbersDefinitions.NonDecimalSeparatorChar;
            this.HalfADozenText          = NumbersDefinitions.HalfADozenText;
            this.WordSeparatorToken      = NumbersDefinitions.WordSeparatorToken;

            this.WrittenDecimalSeparatorTexts  = NumbersDefinitions.WrittenDecimalSeparatorTexts;
            this.WrittenGroupSeparatorTexts    = NumbersDefinitions.WrittenGroupSeparatorTexts;
            this.WrittenIntegerSeparatorTexts  = NumbersDefinitions.WrittenIntegerSeparatorTexts;
            this.WrittenFractionSeparatorTexts = NumbersDefinitions.WrittenFractionSeparatorTexts;

            this.CardinalNumberMap              = NumbersDefinitions.CardinalNumberMap.ToImmutableDictionary();
            this.OrdinalNumberMap               = NumbersDefinitions.OrdinalNumberMap.ToImmutableDictionary();
            this.RelativeReferenceOffsetMap     = NumbersDefinitions.RelativeReferenceOffsetMap.ToImmutableDictionary();
            this.RelativeReferenceRelativeToMap = NumbersDefinitions.RelativeReferenceRelativeToMap.ToImmutableDictionary();
            this.RoundNumberMap = NumbersDefinitions.RoundNumberMap.ToImmutableDictionary();

            this.HalfADozenRegex          = new Regex(NumbersDefinitions.HalfADozenRegex, RegexFlags);
            this.DigitalNumberRegex       = new Regex(NumbersDefinitions.DigitalNumberRegex, RegexFlags);
            this.NegativeNumberSignRegex  = new Regex(NumbersDefinitions.NegativeNumberSignRegex, RegexFlags);
            this.FractionPrepositionRegex = new Regex(NumbersDefinitions.FractionPrepositionRegex, RegexFlags);
            this.RoundMultiplierRegex     = new Regex(NumbersDefinitions.RoundMultiplierRegex, RegexFlags);
        }
예제 #14
0
        public ArabicNumberRangeParserConfiguration(INumberOptionsConfiguration config)
        {
            if (config.Culture == "ar-*")
            {
                CultureInfo = new CultureInfo("ar");
            }
            else
            {
                CultureInfo = new CultureInfo(config.Culture);
            }

            var numConfig = new BaseNumberOptionsConfiguration(config.Culture, config.Options);

            NumberExtractor  = Arabic.NumberExtractor.GetInstance(numConfig);
            OrdinalExtractor = Arabic.OrdinalExtractor.GetInstance(numConfig);
            NumberParser     = new BaseNumberParser(new ArabicNumberParserConfiguration(config));

            MoreOrEqual         = new Regex(NumbersDefinitions.MoreOrEqual, RegexFlags);
            LessOrEqual         = new Regex(NumbersDefinitions.LessOrEqual, RegexFlags);
            MoreOrEqualSuffix   = new Regex(NumbersDefinitions.MoreOrEqualSuffix, RegexFlags);
            LessOrEqualSuffix   = new Regex(NumbersDefinitions.LessOrEqualSuffix, RegexFlags);
            MoreOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags);
            LessOrEqualSeparate = new Regex(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags);
        }
        public NumberRangeExtractor(INumberOptionsConfiguration config)
            : base(NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(config.Culture, config.Options)),
                   OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(config.Culture, config.Options)),
                   new BaseNumberParser(new DutchNumberParserConfiguration(config)),
                   config)
        {
            var regexes = new Dictionary <Regex, string>()
            {
                {
                    // between...and...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex1, RegexFlags),
                    NumberRangeConstants.TWONUMBETWEEN
                },
                {
                    // more than ... less than ...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex2, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // less than ... more than ...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex3, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // from ... to/~/- ...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex4, RegexFlags),
                    NumberRangeConstants.TWONUMTILL
                },
                {
                    // from ... to/~/- ...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex5, RegexFlags),
                    NumberRangeConstants.TWONUMCLOSED
                },
                {
                    // more/greater/higher than ...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // 30 and/or greater/higher
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex2, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // less/smaller/lower than ...
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex1, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    // 30 and/or less/smaller/lower
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex2, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    // equal to ...
                    new Regex(NumbersDefinitions.OneNumberRangeEqualRegex, RegexFlags),
                    NumberRangeConstants.EQUAL
                },
                {
                    // equal to 30 or more than, larger than 30 or equal to ...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // equal to 30 or less, smaller than 30 or equal ...
                    new Regex(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags),
                    NumberRangeConstants.LESS
                },
            };

            Regexes = regexes.ToImmutableDictionary();

            AmbiguousFractionConnectorsRegex =
                new Regex(NumbersDefinitions.AmbiguousFractionConnectorsRegex, RegexFlags);
        }
예제 #16
0
        public NumberRangeExtractor(INumberOptionsConfiguration config)
            : base(new NumberExtractor(), new OrdinalExtractor(), new BaseCJKNumberParser(new ChineseNumberParserConfiguration(config)), config)
        {
            var regexes = new Dictionary <Regex, string>()
            {
                {
                    // 在...和...之间
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex1, RegexOptions.Singleline),
                    NumberRangeConstants.TWONUMBETWEEN
                },
                {
                    // 大于...小于...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex2, RegexOptions.Singleline),
                    NumberRangeConstants.TWONUM
                },
                {
                    // 小于...大于...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex3, RegexOptions.Singleline),
                    NumberRangeConstants.TWONUM
                },
                {
                    // ...到/至..., 20~30
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex4, RegexOptions.Singleline),
                    NumberRangeConstants.TWONUMTILL
                },
                {
                    // 大于/多于/高于...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1, RegexOptions.Singleline),
                    NumberRangeConstants.MORE
                },
                {
                    // 比...大/高/多
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex2, RegexOptions.Singleline),
                    NumberRangeConstants.MORE
                },
                {
                    // ...多/以上/之上
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex3, RegexOptions.Singleline),
                    NumberRangeConstants.MORE
                },
                {
                    // 小于/少于/低于...
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex1, RegexOptions.Singleline),
                    NumberRangeConstants.LESS
                },
                {
                    // 比...小/低/少
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex2, RegexOptions.Singleline),
                    NumberRangeConstants.LESS
                },
                {
                    // .../以下/之下
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex3, RegexOptions.Singleline),
                    NumberRangeConstants.LESS
                },
                {
                    // 等于...
                    new Regex(NumbersDefinitions.OneNumberRangeEqualRegex, RegexOptions.Singleline),
                    NumberRangeConstants.EQUAL
                },
            };

            Regexes = regexes.ToImmutableDictionary();

            AmbiguousFractionConnectorsRegex =
                new Regex(NumbersDefinitions.AmbiguousFractionConnectorsRegex, RegexOptions.Singleline);
        }
예제 #17
0
        public NumberRangeExtractor(INumberOptionsConfiguration config)
            : base(new NumberExtractor(new BaseNumberOptionsConfiguration(config)),
                   new OrdinalExtractor(new BaseNumberOptionsConfiguration(config)),
                   new BaseCJKNumberParser(new KoreanNumberParserConfiguration(config)),
                   config)
        {
            var regexes = new Dictionary <Regex, string>
            {
                {
                    // ...과...사이
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex1, RegexFlags),
                    NumberRangeConstants.TWONUMBETWEEN
                },
                {
                    // 이상...이하...

                    new Regex(NumbersDefinitions.TwoNumberRangeRegex2, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // 이하...이상...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex3, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // 이십보다 크고 삼십오보다 작다
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex7, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // ...에서..., 20~30
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex4, RegexFlags),
                    NumberRangeConstants.TWONUMTILL
                },
                {
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex5, RegexFlags),
                    NumberRangeConstants.TWONUMTILL
                },
                {
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex6, RegexFlags),
                    NumberRangeConstants.TWONUMTILL
                },
                {
                    // ...이상|초과|많|높|크|더많|더높|더크|>
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // ...이상|초과|많|높|크|더많|더높|더크|>
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex2, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // >|≥...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex3, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex5, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // >|≥...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegexFraction, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex1, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex2, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    // 까지최소|<|≤...
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex3, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    new Regex(NumbersDefinitions.OneNumberRangeEqualRegex, RegexFlags),
                    NumberRangeConstants.EQUAL
                },
                {
                    // >|≥...
                    new Regex(NumbersDefinitions.OneNumberRangeEqualRegex2, RegexFlags),
                    NumberRangeConstants.EQUAL
                },
                {
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex4, RegexFlags),
                    NumberRangeConstants.EQUAL
                },
                {
                    // 700에 달하는
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex4, RegexFlags),
                    NumberRangeConstants.LESS
                },
            };

            Regexes = regexes.ToImmutableDictionary();
        }
 public BaseNumberOptionsConfiguration(INumberOptionsConfiguration config)
 {
     Culture = config.Culture;
     Options = config.Options;
     Mode    = config.Mode;
 }
        public NumberRangeExtractor(INumberOptionsConfiguration config)
            : base(NumberExtractor.GetInstance(new BaseNumberOptionsConfiguration(config.Culture, config.Options)),
                   OrdinalExtractor.GetInstance(new BaseNumberOptionsConfiguration(config.Culture, config.Options)),
                   new BaseNumberParser(new SpanishNumberParserConfiguration(config)),
                   config)
        {
            var regexes = new Dictionary <Regex, string>()
            {
                {
                    // entre ...y ...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex1, RegexFlags),
                    NumberRangeConstants.TWONUMBETWEEN
                },
                {
                    // más que ... monos que ...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex2, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // monos que ... más que ...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex3, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // de ... a ...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex4, RegexFlags),
                    NumberRangeConstants.TWONUMTILL
                },
                {
                    // más/mayor que ...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1LB, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // 30 and/or greater/higher
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex2, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // less/smaller/lower than ...
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex1LB, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    // 30 y/o mas/más/mayor/mayores
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex2, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    // igual a ...
                    new Regex(NumbersDefinitions.OneNumberRangeEqualRegex, RegexFlags),
                    NumberRangeConstants.EQUAL
                },
                {
                    // igual a 30 o más, más que 30 o igual ...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreSeparateRegex, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // igual a 30 o menos, menos que 30 o igual ...
                    new Regex(NumbersDefinitions.OneNumberRangeLessSeparateRegex, RegexFlags),
                    NumberRangeConstants.LESS
                },
            };

            Regexes = regexes.ToImmutableDictionary();

            AmbiguousFractionConnectorsRegex =
                new Regex(NumbersDefinitions.AmbiguousFractionConnectorsRegex, RegexFlags);
        }
예제 #20
0
        public NumberRangeExtractor(INumberOptionsConfiguration config)
            : base(new NumberExtractor(new BaseNumberOptionsConfiguration(config)),
                   new OrdinalExtractor(new BaseNumberOptionsConfiguration(config)),
                   new BaseCJKNumberParser(new JapaneseNumberParserConfiguration(config)),
                   config)
        {
            var regexes = new Dictionary <Regex, string>
            {
                {
                    // ...と...の間
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex1, RegexFlags),
                    NumberRangeConstants.TWONUMBETWEEN
                },
                {
                    // より大きい...より小さい...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex2, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // より小さい...より大きい...
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex3, RegexFlags),
                    NumberRangeConstants.TWONUM
                },
                {
                    // ...と/から..., 20~30
                    new Regex(NumbersDefinitions.TwoNumberRangeRegex4, RegexFlags),
                    NumberRangeConstants.TWONUMTILL
                },
                {
                    // 大なり|大きい|高い|大きく...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex1, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // ...以上
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex3, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // 少なくとも|多くて|最大...
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex4, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // ...以上
                    new Regex(NumbersDefinitions.OneNumberRangeMoreRegex5, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // ...以上
                    new Regex(NumbersDefinitions.TwoNumberRangeMoreSuffix, RegexFlags),
                    NumberRangeConstants.MORE
                },
                {
                    // 小なり|小さい|低い...
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex1, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    // ...以下
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex3, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    // ...以下
                    new Regex(NumbersDefinitions.OneNumberRangeLessRegex4, RegexFlags),
                    NumberRangeConstants.LESS
                },
                {
                    // イコール... | ...等しい|
                    new Regex(NumbersDefinitions.OneNumberRangeEqualRegex, RegexFlags),
                    NumberRangeConstants.EQUAL
                },
            };

            Regexes = regexes.ToImmutableDictionary();

            AmbiguousFractionConnectorsRegex =
                new Regex(NumbersDefinitions.AmbiguousFractionConnectorsRegex, RegexFlags);
        }