public NumberExtractor(BaseNumberOptionsConfiguration config, CJKNumberExtractorMode mode = CJKNumberExtractorMode.Default) { var builder = ImmutableDictionary.CreateBuilder <Regex, TypeTag>(); // Add Cardinal var cardExtractChs = new CardinalExtractor(config, mode); builder.AddRange(cardExtractChs.Regexes); // Add Fraction var fracExtractChs = new FractionExtractor(config); builder.AddRange(fracExtractChs.Regexes); Regexes = builder.ToImmutable(); var ambiguityBuilder = ImmutableDictionary.CreateBuilder <Regex, Regex>(); // Do not filter the ambiguous number cases like 'that one' in NumberWithUnit, otherwise they can't be resolved. if (config.Mode != NumberMode.Unit) { foreach (var item in NumbersDefinitions.AmbiguityFiltersDict) { ambiguityBuilder.Add(new Regex(item.Key, RegexFlags), new Regex(item.Value, RegexFlags)); } } AmbiguityFiltersDict = ambiguityBuilder.ToImmutable(); }
public NumberExtractor(ChineseNumberMode mode = ChineseNumberMode.Default) { var builder = ImmutableDictionary.CreateBuilder <Regex, string>(); //Add Cardinal var cardExtractChs = new CardinalExtractor(mode); builder.AddRange(cardExtractChs.Regexes); //Add Fraction var fracExtractChs = new FractionExtractor(); builder.AddRange(fracExtractChs.Regexes); Regexes = builder.ToImmutable(); }
public NumberExtractor(BaseNumberOptionsConfiguration config, CJKNumberExtractorMode mode = CJKNumberExtractorMode.Default) { var builder = ImmutableDictionary.CreateBuilder <Regex, TypeTag>(); // Add Cardinal var cardExtractChs = new CardinalExtractor(config, mode); builder.AddRange(cardExtractChs.Regexes); // Add Fraction var fracExtractChs = new FractionExtractor(config); builder.AddRange(fracExtractChs.Regexes); Regexes = builder.ToImmutable(); }