コード例 #1
0
        public ChineseMergedExtractorConfiguration(IDateTimeOptionsConfiguration config)
        {
            this.config = config;

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(DateTimeDefinitions.AmbiguityFiltersDict);
            HolidayExtractor     = new BaseHolidayExtractor(new ChineseHolidayExtractorConfiguration(config));
        }
コード例 #2
0
        public SpanishMergedExtractorConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            DateExtractor           = new BaseDateExtractor(new SpanishDateExtractorConfiguration(this));
            TimeExtractor           = new BaseTimeExtractor(new SpanishTimeExtractorConfiguration(this));
            DateTimeExtractor       = new BaseDateTimeExtractor(new SpanishDateTimeExtractorConfiguration(this));
            DatePeriodExtractor     = new BaseDatePeriodExtractor(new SpanishDatePeriodExtractorConfiguration(this));
            TimePeriodExtractor     = new BaseTimePeriodExtractor(new SpanishTimePeriodExtractorConfiguration(this));
            DateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new SpanishDateTimePeriodExtractorConfiguration(this));
            DurationExtractor       = new BaseDurationExtractor(new SpanishDurationExtractorConfiguration(this));
            SetExtractor            = new BaseSetExtractor(new SpanishSetExtractorConfiguration(this));
            DateTimeAltExtractor    = new BaseDateTimeAltExtractor(new SpanishDateTimeAltExtractorConfiguration(this));
            HolidayExtractor        = new BaseHolidayExtractor(new SpanishHolidayExtractorConfiguration(this));
            TimeZoneExtractor       = new BaseTimeZoneExtractor(new SpanishTimeZoneExtractorConfiguration(this));

            var numOptions = NumberOptions.None;

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

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

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

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(DateTimeDefinitions.AmbiguityFiltersDict);
        }
コード例 #3
0
        public DutchMergedExtractorConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            DateExtractor           = new BaseDateExtractor(new DutchDateExtractorConfiguration(this));
            TimeExtractor           = new BaseTimeExtractor(new DutchTimeExtractorConfiguration(this));
            DateTimeExtractor       = new BaseDateTimeExtractor(new DutchDateTimeExtractorConfiguration(this));
            DatePeriodExtractor     = new BaseDatePeriodExtractor(new DutchDatePeriodExtractorConfiguration(this));
            TimePeriodExtractor     = new BaseTimePeriodExtractor(new DutchTimePeriodExtractorConfiguration(this));
            DateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new DutchDateTimePeriodExtractorConfiguration(this));
            DurationExtractor       = new BaseDurationExtractor(new DutchDurationExtractorConfiguration(this));
            SetExtractor            = new BaseSetExtractor(new DutchSetExtractorConfiguration(this));
            HolidayExtractor        = new BaseHolidayExtractor(new DutchHolidayExtractorConfiguration(this));
            TimeZoneExtractor       = new BaseTimeZoneExtractor(new DutchTimeZoneExtractorConfiguration(this));
            DateTimeAltExtractor    = new BaseDateTimeAltExtractor(new DutchDateTimeAltExtractorConfiguration(this));

            var numOptions = NumberOptions.None;

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

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

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

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(DateTimeDefinitions.AmbiguityFiltersDict);

            if ((Options & DateTimeOptions.EnablePreview) != 0)
            {
                SuperfluousWordMatcher.Init(DateTimeDefinitions.SuperfluousWordList);
            }
        }
コード例 #4
0
        protected JapaneseNumberWithUnitExtractorConfiguration(CultureInfo ci)
        {
            this.CultureInfo      = ci;
            this.UnitNumExtractor = new NumberExtractor(CJKNumberExtractorMode.ExtractAll);
            this.BuildPrefix      = NumbersWithUnitDefinitions.BuildPrefix;
            this.BuildSuffix      = NumbersWithUnitDefinitions.BuildSuffix;
            this.ConnectorToken   = NumbersWithUnitDefinitions.ConnectorToken;

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.AmbiguityFiltersDict);
        }
コード例 #5
0
 public ChinesePhoneNumberExtractorConfiguration(SequenceOptions options)
     : base(options)
 {
     WordBoundariesRegex    = PhoneNumbersDefinitions.WordBoundariesRegex;
     NonWordBoundariesRegex = PhoneNumbersDefinitions.NonWordBoundariesRegex;
     EndWordBoundariesRegex = PhoneNumbersDefinitions.EndWordBoundariesRegex;
     ColonPrefixCheckRegex  = new Regex(PhoneNumbersDefinitions.ColonPrefixCheckRegex);
     ForbiddenPrefixMarkers = (List <char>)PhoneNumbersDefinitions.ForbiddenPrefixMarkers;
     AmbiguityFiltersDict   = AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(BasePhoneNumbers.AmbiguityFiltersDict);
 }
        protected HindiNumberWithUnitExtractorConfiguration(CultureInfo ci)
        {
            this.CultureInfo      = ci;
            this.UnitNumExtractor = NumberExtractor.GetInstance(NumberMode.Unit);
            this.BuildPrefix      = NumbersWithUnitDefinitions.BuildPrefix;
            this.BuildSuffix      = NumbersWithUnitDefinitions.BuildSuffix;
            this.ConnectorToken   = string.Empty;

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.AmbiguityFiltersDict);
        }
コード例 #7
0
        public JapaneseDurationExtractorConfiguration(IDateTimeOptionsConfiguration config, bool merge = true)
            : base(config)
        {
            this.merge = merge;

            InternalExtractor = new NumberWithUnitExtractor(new DurationExtractorConfiguration());

            UnitMap      = DateTimeDefinitions.ParserConfigurationUnitMap.ToDictionary(k => k.Key, k => k.Value);
            UnitValueMap = DateTimeDefinitions.DurationUnitValueMap;
            AmbiguityDurationFiltersDict = DefinitionLoader.LoadAmbiguityFilters(DateTimeDefinitions.AmbiguityDurationFiltersDict);
        }
        protected ItalianNumberWithUnitExtractorConfiguration(CultureInfo ci)
        {
            this.CultureInfo      = ci;
            this.UnitNumExtractor = NumberExtractor.GetInstance(NumberMode.Unit);
            this.BuildPrefix      = NumbersWithUnitDefinitions.BuildPrefix;
            this.BuildSuffix      = NumbersWithUnitDefinitions.BuildSuffix;
            this.ConnectorToken   = NumbersWithUnitDefinitions.ConnectorToken;

            AmbiguityFiltersDict            = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.AmbiguityFiltersDict);
            TemperatureAmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.TemperatureAmbiguityFiltersDict);
            DimensionAmbiguityFiltersDict   = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.DimensionAmbiguityFiltersDict);
        }
コード例 #9
0
        protected FrenchNumberWithUnitExtractorConfiguration(CultureInfo ci)
        {
            this.CultureInfo                = ci;
            this.UnitNumExtractor           = NumberExtractor.GetInstance();
            this.BuildPrefix                = NumbersWithUnitDefinitions.BuildPrefix;
            this.BuildSuffix                = NumbersWithUnitDefinitions.BuildSuffix;
            this.ConnectorToken             = NumbersWithUnitDefinitions.ConnectorToken;
            this.CompoundUnitConnectorRegex = new Regex(NumbersWithUnitDefinitions.CompoundUnitConnectorRegex, RegexOptions.IgnoreCase);
            this.PmNonUnitRegex             = new Regex(BaseUnits.PmNonUnitRegex, RegexOptions.IgnoreCase);

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.AmbiguityFiltersDict);
        }
        protected KoreanNumberWithUnitExtractorConfiguration(CultureInfo ci)
        {
            this.CultureInfo = ci;

            var numConfig = new BaseNumberOptionsConfiguration(ci.Name, NumberOptions.None);

            this.UnitNumExtractor = new NumberExtractor(KoreanNumberExtractorMode.ExtractAll);

            this.BuildPrefix    = NumbersWithUnitDefinitions.BuildPrefix;
            this.BuildSuffix    = NumbersWithUnitDefinitions.BuildSuffix;
            this.ConnectorToken = NumbersWithUnitDefinitions.ConnectorToken;

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.AmbiguityFiltersDict);
        }
        protected GermanNumberWithUnitExtractorConfiguration(CultureInfo ci)
        {
            this.CultureInfo = ci;

            var unitNumConfig = new BaseNumberOptionsConfiguration(ci.Name, NumberOptions.None, NumberMode.Unit);

            this.UnitNumExtractor = NumberExtractor.GetInstance(unitNumConfig);

            this.BuildPrefix    = NumbersWithUnitDefinitions.BuildPrefix;
            this.BuildSuffix    = NumbersWithUnitDefinitions.BuildSuffix;
            this.ConnectorToken = NumbersWithUnitDefinitions.ConnectorToken;

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.AmbiguityFiltersDict);
        }
コード例 #12
0
        public ChineseMergedExtractorConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(DateTimeDefinitions.AmbiguityFiltersDict);

            DateExtractor           = new BaseCJKDateExtractor(new ChineseDateExtractorConfiguration(this));
            TimeExtractor           = new BaseCJKTimeExtractor(new ChineseTimeExtractorConfiguration(this));
            DateTimeExtractor       = new BaseCJKDateTimeExtractor(new ChineseDateTimeExtractorConfiguration(this));
            DatePeriodExtractor     = new BaseCJKDatePeriodExtractor(new ChineseDatePeriodExtractorConfiguration(this));
            TimePeriodExtractor     = new BaseCJKTimePeriodExtractor(new ChineseTimePeriodExtractorConfiguration(this));
            DateTimePeriodExtractor = new BaseCJKDateTimePeriodExtractor(new ChineseDateTimePeriodExtractorConfiguration(this));
            DurationExtractor       = new BaseCJKDurationExtractor(new ChineseDurationExtractorConfiguration(this));
            SetExtractor            = new BaseCJKSetExtractor(new ChineseSetExtractorConfiguration(this));
            HolidayExtractor        = new BaseCJKHolidayExtractor(new ChineseHolidayExtractorConfiguration(this));
        }
コード例 #13
0
        protected SwedishNumberWithUnitExtractorConfiguration(CultureInfo ci)
        {
            this.CultureInfo = ci;

            var unitNumConfig = new BaseNumberOptionsConfiguration(ci.Name, NumberOptions.None, NumberMode.Unit);

            this.UnitNumExtractor = NumberExtractor.GetInstance(unitNumConfig);

            this.BuildPrefix    = NumbersWithUnitDefinitions.BuildPrefix;
            this.BuildSuffix    = NumbersWithUnitDefinitions.BuildSuffix;
            this.ConnectorToken = string.Empty;

            AmbiguityFiltersDict            = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.AmbiguityFiltersDict);
            TemperatureAmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.TemperatureAmbiguityFiltersDict);
            DimensionAmbiguityFiltersDict   = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.DimensionAmbiguityFiltersDict);
        }
コード例 #14
0
        public GermanMergedExtractorConfiguration(DateTimeOptions options) : base(options)
        {
            DateExtractor           = new BaseDateExtractor(new GermanDateExtractorConfiguration(this));
            TimeExtractor           = new BaseTimeExtractor(new GermanTimeExtractorConfiguration(this));
            DateTimeExtractor       = new BaseDateTimeExtractor(new GermanDateTimeExtractorConfiguration(this));
            DatePeriodExtractor     = new BaseDatePeriodExtractor(new GermanDatePeriodExtractorConfiguration(this));
            TimePeriodExtractor     = new BaseTimePeriodExtractor(new GermanTimePeriodExtractorConfiguration(this));
            DateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new GermanDateTimePeriodExtractorConfiguration(this));
            DurationExtractor       = new BaseDurationExtractor(new GermanDurationExtractorConfiguration(this));
            SetExtractor            = new BaseSetExtractor(new GermanSetExtractorConfiguration(this));
            HolidayExtractor        = new BaseHolidayExtractor(new GermanHolidayExtractorConfiguration(this));
            TimeZoneExtractor       = new BaseTimeZoneExtractor(new GermanTimeZoneExtractorConfiguration(this));
            IntegerExtractor        = Number.German.IntegerExtractor.GetInstance();
            DateTimeAltExtractor    = new BaseDateTimeAltExtractor(new GermanDateTimeAltExtractorConfiguration(this));

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(DateTimeDefinitions.AmbiguityFiltersDict);
        }
        protected EnglishNumberWithUnitExtractorConfiguration(CultureInfo ci)
        {
            this.CultureInfo = ci;

            // PlaceHolderMixed allows to extract numbers from expressions like 'USD15', '15USD' where there is no space between
            // alphabetic and numeric characters (PlaeHolderDefault does not extract numbers from expressions like 'USD15').
            var unitNumConfig = new BaseNumberOptionsConfiguration(ci.Name, NumberOptions.None, NumberMode.Unit, BaseNumbers.PlaceHolderMixed);

            this.UnitNumExtractor = NumberExtractor.GetInstance(unitNumConfig);

            this.BuildPrefix    = NumbersWithUnitDefinitions.BuildPrefix;
            this.BuildSuffix    = NumbersWithUnitDefinitions.BuildSuffix;
            this.ConnectorToken = string.Empty;

            AmbiguityFiltersDict            = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.AmbiguityFiltersDict);
            TemperatureAmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.TemperatureAmbiguityFiltersDict);
            DimensionAmbiguityFiltersDict   = DefinitionLoader.LoadAmbiguityFilters(NumbersWithUnitDefinitions.DimensionAmbiguityFiltersDict);
        }
コード例 #16
0
        public FrenchMergedExtractorConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            DateExtractor           = new BaseDateExtractor(new FrenchDateExtractorConfiguration(this));
            TimeExtractor           = new BaseTimeExtractor(new FrenchTimeExtractorConfiguration(this));
            DateTimeExtractor       = new BaseDateTimeExtractor(new FrenchDateTimeExtractorConfiguration(this));
            DatePeriodExtractor     = new BaseDatePeriodExtractor(new FrenchDatePeriodExtractorConfiguration(this));
            TimePeriodExtractor     = new BaseTimePeriodExtractor(new FrenchTimePeriodExtractorConfiguration(this));
            DateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new FrenchDateTimePeriodExtractorConfiguration(this));
            DurationExtractor       = new BaseDurationExtractor(new FrenchDurationExtractorConfiguration(this));
            SetExtractor            = new BaseSetExtractor(new FrenchSetExtractorConfiguration(this));
            HolidayExtractor        = new BaseHolidayExtractor(new FrenchHolidayExtractorConfiguration(this));
            TimeZoneExtractor       = new BaseTimeZoneExtractor(new FrenchTimeZoneExtractorConfiguration(this));
            DateTimeAltExtractor    = new BaseDateTimeAltExtractor(new FrenchDateTimeAltExtractorConfiguration(this));
            IntegerExtractor        = Number.French.IntegerExtractor.GetInstance();

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(DateTimeDefinitions.AmbiguityFiltersDict);
        }
コード例 #17
0
        public NumberExtractor(BaseNumberOptionsConfiguration config, CJKNumberExtractorMode mode = CJKNumberExtractorMode.Default)
        {
            var builder = ImmutableDictionary.CreateBuilder <Regex, TypeTag>();

            // Add Cardinal
            var cardExtract = new CardinalExtractor(config, mode);

            builder.AddRange(cardExtract.Regexes);

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

            builder.AddRange(fracExtract.Regexes);

            Regexes = builder.ToImmutable();

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(NumbersDefinitions.AmbiguityFiltersDict).ToImmutableDictionary();
        }
コード例 #18
0
        public HindiMergedExtractorConfiguration(IDateTimeOptionsConfiguration config)
            : base(config)
        {
            DateExtractor           = new BaseDateExtractor(new HindiDateExtractorConfiguration(this));
            TimeExtractor           = new BaseTimeExtractor(new HindiTimeExtractorConfiguration(this));
            DateTimeExtractor       = new BaseDateTimeExtractor(new HindiDateTimeExtractorConfiguration(this));
            DatePeriodExtractor     = new BaseDatePeriodExtractor(new HindiDatePeriodExtractorConfiguration(this));
            TimePeriodExtractor     = new BaseTimePeriodExtractor(new HindiTimePeriodExtractorConfiguration(this));
            DateTimePeriodExtractor = new BaseDateTimePeriodExtractor(new HindiDateTimePeriodExtractorConfiguration(this));
            DurationExtractor       = new BaseDurationExtractor(new HindiDurationExtractorConfiguration(this));
            SetExtractor            = new BaseSetExtractor(new HindiSetExtractorConfiguration(this));
            HolidayExtractor        = new BaseHolidayExtractor(new HindiHolidayExtractorConfiguration(this));
            DateTimeAltExtractor    = new BaseDateTimeAltExtractor(new HindiDateTimeAltExtractorConfiguration(this));
            IntegerExtractor        = Number.Hindi.IntegerExtractor.GetInstance();

            AmbiguityFiltersDict = DefinitionLoader.LoadAmbiguityFilters(DateTimeDefinitions.AmbiguityFiltersDict);

            if ((Options & DateTimeOptions.EnablePreview) != 0)
            {
                SuperfluousWordMatcher.Init(DateTimeDefinitions.SuperfluousWordList);
            }
        }