コード例 #1
0
 public EnglishTimePeriodExtractorConfiguration(IOptionsConfiguration config) : base(config)
 {
     TokenBeforeDate      = DateTimeDefinitions.TokenBeforeDate;
     SingleTimeExtractor  = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration(this));
     UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();
     IntegerExtractor     = Number.English.IntegerExtractor.GetInstance();
 }
コード例 #2
0
        public EnglishDateExtractorConfiguration(DateTimeOptions options = DateTimeOptions.None)
        {
            Options              = options;
            IntegerExtractor     = Number.English.IntegerExtractor.GetInstance();
            OrdinalExtractor     = Number.English.OrdinalExtractor.GetInstance();
            NumberParser         = new BaseNumberParser(new EnglishNumberParserConfiguration());
            DurationExtractor    = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration());
            UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();
            var implicitDateList = new List <Regex>
            {
                OnRegex,
                RelaxedOnRegex,
                SpecialDayRegex,
                ThisRegex,
                LastDateRegex,
                NextDateRegex,
                SingleWeekDayRegex,
                WeekDayOfMonthRegex,
                SpecialDate,
                SpecialDayWithNumRegex,
                RelativeWeekDayRegex
            };

            if ((Options & DateTimeOptions.CalendarMode) != 0)
            {
                implicitDateList.Add(DayRegex);
            }

            ImplicitDateList = implicitDateList;
        }
コード例 #3
0
 public EnglishDateTimeExtractorConfiguration(IOptionsConfiguration config) : base(config)
 {
     IntegerExtractor     = Number.English.IntegerExtractor.GetInstance();
     DatePointExtractor   = new BaseDateExtractor(new EnglishDateExtractorConfiguration(this));
     TimePointExtractor   = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration(this));
     DurationExtractor    = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration(this));
     UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();
 }
 public EnglishDateTimeExtractorConfiguration(DateTimeOptions options = DateTimeOptions.None) : base(options)
 {
     IntegerExtractor     = Number.English.IntegerExtractor.GetInstance();
     DatePointExtractor   = new BaseDateExtractor(new EnglishDateExtractorConfiguration());
     TimePointExtractor   = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration());
     DurationExtractor    = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration());
     UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();
 }
コード例 #5
0
 public EnglishDateExtractorConfiguration()
 {
     Options              = DateTimeOptions.None;
     IntegerExtractor     = Number.English.IntegerExtractor.GetInstance();
     OrdinalExtractor     = Number.English.OrdinalExtractor.GetInstance();
     NumberParser         = new BaseNumberParser(new EnglishNumberParserConfiguration());
     DurationExtractor    = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration());
     UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();
 }
        public EnglishCommonDateTimeParserConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();

            UnitMap                = DateTimeDefinitions.UnitMap.ToImmutableDictionary();
            UnitValueMap           = DateTimeDefinitions.UnitValueMap.ToImmutableDictionary();
            SeasonMap              = DateTimeDefinitions.SeasonMap.ToImmutableDictionary();
            SpecialYearPrefixesMap = DateTimeDefinitions.SpecialYearPrefixesMap.ToImmutableDictionary();
            CardinalMap            = DateTimeDefinitions.CardinalMap.ToImmutableDictionary();
            DayOfWeek              = DateTimeDefinitions.DayOfWeek.ToImmutableDictionary();
            MonthOfYear            = DateTimeDefinitions.MonthOfYear.ToImmutableDictionary();
            Numbers                = DateTimeDefinitions.Numbers.ToImmutableDictionary();
            DoubleNumbers          = DateTimeDefinitions.DoubleNumbers.ToImmutableDictionary();
            WrittenDecades         = DateTimeDefinitions.WrittenDecades.ToImmutableDictionary();
            SpecialDecadeCases     = DateTimeDefinitions.SpecialDecadeCases.ToImmutableDictionary();

            var numOptions = NumberOptions.None;

            if ((config.Options & DateTimeOptions.NoProtoCache) != 0)
            {
                numOptions = NumberOptions.NoProtoCache;
            }

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

            CardinalExtractor = Number.English.CardinalExtractor.GetInstance(numConfig);
            IntegerExtractor  = Number.English.IntegerExtractor.GetInstance(numConfig);
            OrdinalExtractor  = Number.English.OrdinalExtractor.GetInstance(numConfig);

            NumberParser = new BaseNumberParser(new EnglishNumberParserConfiguration(numConfig));

            TimeZoneParser = new BaseTimeZoneParser();

            // Do not change order. The order of initialization can lead to side-effects
            DateExtractor           = new BaseDateExtractor(new EnglishDateExtractorConfiguration(this));
            TimeExtractor           = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration(this));
            DateTimeExtractor       = new BaseDateTimeExtractor(new EnglishDateTimeExtractorConfiguration(this));
            DurationExtractor       = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration(this));
            DatePeriodExtractor     = new BaseDatePeriodExtractor(new EnglishDatePeriodExtractorConfiguration(this));
            TimePeriodExtractor     = new BaseTimePeriodExtractor(new EnglishTimePeriodExtractorConfiguration(this));
            DateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new EnglishDateTimePeriodExtractorConfiguration(this));

            DurationParser       = new BaseDurationParser(new EnglishDurationParserConfiguration(this));
            DateParser           = new BaseDateParser(new EnglishDateParserConfiguration(this));
            TimeParser           = new TimeParser(new EnglishTimeParserConfiguration(this));
            DateTimeParser       = new BaseDateTimeParser(new EnglishDateTimeParserConfiguration(this));
            DatePeriodParser     = new BaseDatePeriodParser(new EnglishDatePeriodParserConfiguration(this));
            TimePeriodParser     = new BaseTimePeriodParser(new EnglishTimePeriodParserConfiguration(this));
            DateTimePeriodParser = new BaseDateTimePeriodParser(new EnglishDateTimePeriodParserConfiguration(this));

            DateTimeAltParser = new BaseDateTimeAltParser(new EnglishDateTimeAltParserConfiguration(this));
        }
コード例 #7
0
        public EnglishDateTimeExtractorConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            var numOptions = NumberOptions.None;

            if ((config.Options & DateTimeOptions.NoProtoCache) != 0)
            {
                numOptions = NumberOptions.NoProtoCache;
            }

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

            IntegerExtractor = Number.English.IntegerExtractor.GetInstance(numConfig);

            DatePointExtractor   = new BaseDateExtractor(new EnglishDateExtractorConfiguration(this));
            TimePointExtractor   = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration(this));
            DurationExtractor    = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration(this));
            UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();
        }
        public EnglishTimePeriodExtractorConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            TokenBeforeDate      = DateTimeDefinitions.TokenBeforeDate;
            SingleTimeExtractor  = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration(this));
            UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();

            var numOptions = NumberOptions.None;

            if ((config.Options & DateTimeOptions.NoProtoCache) != 0)
            {
                numOptions = NumberOptions.NoProtoCache;
            }

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

            IntegerExtractor = Number.English.IntegerExtractor.GetInstance(numConfig);

            TimeZoneExtractor = new BaseTimeZoneExtractor(new EnglishTimeZoneExtractorConfiguration(this));
        }
コード例 #9
0
        public EnglishCommonDateTimeParserConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();

            UnitMap                = DateTimeDefinitions.UnitMap.ToImmutableDictionary();
            UnitValueMap           = DateTimeDefinitions.UnitValueMap.ToImmutableDictionary();
            SeasonMap              = DateTimeDefinitions.SeasonMap.ToImmutableDictionary();
            SpecialYearPrefixesMap = DateTimeDefinitions.SpecialYearPrefixesMap.ToImmutableDictionary();
            CardinalMap            = DateTimeDefinitions.CardinalMap.ToImmutableDictionary();
            DayOfWeek              = DateTimeDefinitions.DayOfWeek.ToImmutableDictionary();
            MonthOfYear            = DateTimeDefinitions.MonthOfYear.ToImmutableDictionary();
            Numbers                = DateTimeDefinitions.Numbers.ToImmutableDictionary();
            DoubleNumbers          = DateTimeDefinitions.DoubleNumbers.ToImmutableDictionary();
            WrittenDecades         = DateTimeDefinitions.WrittenDecades.ToImmutableDictionary();
            SpecialDecadeCases     = DateTimeDefinitions.SpecialDecadeCases.ToImmutableDictionary();

            CardinalExtractor = Number.English.CardinalExtractor.GetInstance();
            IntegerExtractor  = Number.English.IntegerExtractor.GetInstance();
            OrdinalExtractor  = Number.English.OrdinalExtractor.GetInstance();

            TimeZoneParser          = new BaseTimeZoneParser();
            NumberParser            = new BaseNumberParser(new EnglishNumberParserConfiguration(new BaseNumberOptionsConfiguration(config.Culture)));
            DateExtractor           = new BaseDateExtractor(new EnglishDateExtractorConfiguration(this));
            TimeExtractor           = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration(this));
            DateTimeExtractor       = new BaseDateTimeExtractor(new EnglishDateTimeExtractorConfiguration(this));
            DurationExtractor       = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration(this));
            DatePeriodExtractor     = new BaseDatePeriodExtractor(new EnglishDatePeriodExtractorConfiguration(this));
            TimePeriodExtractor     = new BaseTimePeriodExtractor(new EnglishTimePeriodExtractorConfiguration(this));
            DateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new EnglishDateTimePeriodExtractorConfiguration(this));
            DurationParser          = new BaseDurationParser(new EnglishDurationParserConfiguration(this));
            DateParser           = new BaseDateParser(new EnglishDateParserConfiguration(this));
            TimeParser           = new TimeParser(new EnglishTimeParserConfiguration(this));
            DateTimeParser       = new BaseDateTimeParser(new EnglishDateTimeParserConfiguration(this));
            DatePeriodParser     = new BaseDatePeriodParser(new EnglishDatePeriodParserConfiguration(this));
            TimePeriodParser     = new BaseTimePeriodParser(new EnglishTimePeriodParserConfiguration(this));
            DateTimePeriodParser = new BaseDateTimePeriodParser(new EnglishDateTimePeriodParserConfiguration(this));
            DateTimeAltParser    = new BaseDateTimeAltParser(new EnglishDateTimeAltParserConfiguration(this));
        }
コード例 #10
0
        public EnglishDateExtractorConfiguration(IOptionsConfiguration config)
            : base(config)
        {
            IntegerExtractor = Number.English.IntegerExtractor.GetInstance();
            OrdinalExtractor = Number.English.OrdinalExtractor.GetInstance();

            NumberParser         = new BaseNumberParser(new EnglishNumberParserConfiguration());
            DurationExtractor    = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration(this));
            UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();

            ImplicitDateList = new List <Regex>
            {
                // extract "12" from "on 12"
                OnRegex,

                // extract "12th" from "on/at/in 12th"
                RelaxedOnRegex,

                // "the day before yesterday", "previous day", "today", "yesterday", "tomorrow"
                SpecialDayRegex,

                // "this Monday", "Tuesday of this week"
                ThisRegex,

                // "last/previous Monday", "Monday of last week"
                LastDateRegex,

                // "next/following Monday", "Monday of next week"
                NextDateRegex,

                // "Sunday", "Weds"
                SingleWeekDayRegex,

                // "2nd Monday of April"
                WeekDayOfMonthRegex,

                // "on the 12th"
                SpecialDate,

                // "two days from today", "five days from tomorrow"
                SpecialDayWithNumRegex,

                // "three Monday from now"
                RelativeWeekDayRegex,
            };

            if ((Options & DateTimeOptions.CalendarMode) != 0)
            {
                ImplicitDateList = ImplicitDateList.Concat(new[] { DayRegex });
            }

            // 3-23-2017
            var dateRegex4 = new Regex(DateTimeDefinitions.DateExtractor4, RegexFlags);

            // 23-3-2015
            var dateRegex5 = new Regex(DateTimeDefinitions.DateExtractor5, RegexFlags);

            // on (Sunday,)? 1.3
            var dateRegex6 = new Regex(DateTimeDefinitions.DateExtractor6, RegexFlags);

            // on (Sunday,)? 24-12
            var dateRegex8 = new Regex(DateTimeDefinitions.DateExtractor8, RegexFlags);

            // "(Sunday,)? 7/23, 2018", year part is required
            var dateRegex7L = new Regex(DateTimeDefinitions.DateExtractor7L, RegexFlags);

            // "(Sunday,)? 7/23", year part is not required
            var dateRegex7S = new Regex(DateTimeDefinitions.DateExtractor7S, RegexFlags);

            // "(Sunday,)? 23/7, 2018", year part is required
            var dateRegex9L = new Regex(DateTimeDefinitions.DateExtractor9L, RegexFlags);

            // "(Sunday,)? 23/7", year part is not required
            var dateRegex9S = new Regex(DateTimeDefinitions.DateExtractor9S, RegexFlags);

            // (Sunday,)? 2015-12-23
            var dateRegexA = new Regex(DateTimeDefinitions.DateExtractorA, RegexFlags);

            DateRegexList = new List <Regex>
            {
                // (Sunday,)? April 5 or (Sunday,)? April 5, 2016
                new Regex(DateTimeDefinitions.DateExtractor1, RegexFlags),

                // (Sunday,)? 6th of April
                new Regex(DateTimeDefinitions.DateExtractor3, RegexFlags),
            };

            var enableDmy = DmyDateFormat ||
                            DateTimeDefinitions.DefaultLanguageFallback == Constants.DefaultLanguageFallback_DMY;

            DateRegexList = DateRegexList.Concat(enableDmy ?
                                                 new[] { dateRegex5, dateRegex8, dateRegex9L, dateRegex9S, dateRegex4, dateRegex6, dateRegex7L, dateRegex7S, dateRegexA } :
                                                 new[] { dateRegex4, dateRegex6, dateRegex7L, dateRegex7S, dateRegex5, dateRegex8, dateRegex9L, dateRegex9S, dateRegexA });
        }
コード例 #11
0
        public EnglishDateExtractorConfiguration(IOptionsConfiguration config) : base(config)
        {
            IntegerExtractor     = Number.English.IntegerExtractor.GetInstance();
            OrdinalExtractor     = Number.English.OrdinalExtractor.GetInstance();
            NumberParser         = new BaseNumberParser(new EnglishNumberParserConfiguration());
            DurationExtractor    = new BaseDurationExtractor(new EnglishDurationExtractorConfiguration(this));
            UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();
            ImplicitDateList     = new List <Regex>
            {
                OnRegex,
                RelaxedOnRegex,
                SpecialDayRegex,
                ThisRegex,
                LastDateRegex,
                NextDateRegex,
                SingleWeekDayRegex,
                WeekDayOfMonthRegex,
                SpecialDate,
                SpecialDayWithNumRegex,
                RelativeWeekDayRegex
            };

            if ((Options & DateTimeOptions.CalendarMode) != 0)
            {
                ImplicitDateList = ImplicitDateList.Concat(new[] { DayRegex });
            }

            const RegexOptions dateRegexOption = RegexOptions.IgnoreCase | RegexOptions.Singleline;

            // 3-23-2017
            var dateRegex4 = new Regex(DateTimeDefinitions.DateExtractor4, dateRegexOption);

            // 23-3-2015
            var dateRegex5 = new Regex(DateTimeDefinitions.DateExtractor5, dateRegexOption);

            // on (Sunday,)? 1.3
            var dateRegex6 = new Regex(DateTimeDefinitions.DateExtractor6, dateRegexOption);

            // on (Sunday,)? 24-12
            var dateRegex8 = new Regex(DateTimeDefinitions.DateExtractor8, dateRegexOption);

            // (Sunday,)? 7/23
            var dateRegex7 = new Regex(DateTimeDefinitions.DateExtractor7, dateRegexOption);

            // (Sunday,)? 23/7
            var dateRegex9 = new Regex(DateTimeDefinitions.DateExtractor9, dateRegexOption);

            // (Sunday,)? 2015-12-23
            var dateRegexA = new Regex(DateTimeDefinitions.DateExtractorA, dateRegexOption);

            DateRegexList = new List <Regex>
            {
                // ((this)? Sunday,)? April 5
                new Regex(DateTimeDefinitions.DateExtractor1, dateRegexOption),

                // ((this)? Sunday,)? April 5, 2016
                new Regex(DateTimeDefinitions.DateExtractor2, dateRegexOption),

                // (Sunday,)? 6th of April
                new Regex(DateTimeDefinitions.DateExtractor3, dateRegexOption),
            };

            var enableDmy = DmyDateFormat ||
                            DateTimeDefinitions.DefaultLanguageFallback == Constants.DefaultLanguageFallback_DMY;

            DateRegexList = DateRegexList.Concat(enableDmy ?
                                                 new[] { dateRegex5, dateRegex8, dateRegex9, dateRegex4, dateRegex6, dateRegex7, dateRegexA } :
                                                 new[] { dateRegex4, dateRegex6, dateRegex7, dateRegex5, dateRegex8, dateRegex9, dateRegexA });
        }
 public EnglishTimePeriodExtractorConfiguration(DateTimeOptions options = DateTimeOptions.None) : base(options)
 {
     SingleTimeExtractor  = new BaseTimeExtractor(new EnglishTimeExtractorConfiguration(options));
     UtilityConfiguration = new EnglishDatetimeUtilityConfiguration();
     IntegerExtractor     = Number.English.IntegerExtractor.GetInstance();
 }