internal TextFeaturizingEstimator(IHostEnvironment env, string name, IEnumerable <string> source, Options options = null) { Contracts.CheckValue(env, nameof(env)); _host = env.Register(nameof(TextFeaturizingEstimator)); _host.CheckValue(source, nameof(source)); _host.CheckParam(source.Any(), nameof(source)); _host.CheckParam(!source.Any(string.IsNullOrWhiteSpace), nameof(source)); _host.CheckNonEmpty(name, nameof(name)); _host.CheckValueOrNull(options); _inputColumns = source.ToArray(); OutputColumn = name; OptionalSettings = new Options(); if (options != null) { OptionalSettings = options; } _dictionary = null; if (OptionalSettings.UseWordExtractor) { _wordFeatureExtractor = new NgramExtractorTransform.NgramExtractorArguments(); } if (OptionalSettings.UseCharExtractor) { _charFeatureExtractor = new NgramExtractorTransform.NgramExtractorArguments() { NgramLength = 3, AllLengths = false } } ; }
public TextTransform(IHostEnvironment env, IEnumerable <string> inputColumns, string outputColumn, Action <Settings> advancedSettings = null) { Contracts.CheckValue(env, nameof(env)); _host = env.Register(nameof(TextTransform)); _host.CheckValue(inputColumns, nameof(inputColumns)); _host.CheckParam(inputColumns.Any(), nameof(inputColumns)); _host.CheckParam(!inputColumns.Any(string.IsNullOrWhiteSpace), nameof(inputColumns)); _host.CheckNonEmpty(outputColumn, nameof(outputColumn)); _host.CheckValueOrNull(advancedSettings); _inputColumns = inputColumns.ToArray(); OutputColumn = outputColumn; AdvancedSettings = new Settings(); advancedSettings?.Invoke(AdvancedSettings); _stopWordsRemover = null; _dictionary = null; _wordFeatureExtractor = new NgramExtractorTransform.NgramExtractorArguments(); _charFeatureExtractor = new NgramExtractorTransform.NgramExtractorArguments() { NgramLength = 3, AllLengths = false }; }
internal TextFeaturizingEstimator(IHostEnvironment env, string name, IEnumerable<string> source, Options options = null) { Contracts.CheckValue(env, nameof(env)); _host = env.Register(nameof(TextFeaturizingEstimator)); _host.CheckValue(source, nameof(source)); _host.CheckParam(source.Any(), nameof(source)); _host.CheckParam(!source.Any(string.IsNullOrWhiteSpace), nameof(source)); _host.CheckNonEmpty(name, nameof(name)); _host.CheckValueOrNull(options); _inputColumns = source.ToArray(); OutputColumn = name; OptionalSettings = new Options(); if (options != null) OptionalSettings = options; _dictionary = null; _wordFeatureExtractor = OptionalSettings.WordFeatureExtractorFactory; _charFeatureExtractor = OptionalSettings.CharFeatureExtractorFactory; }