Skip to content

Commit c2fabb8

Browse files
authored
[Tiny] Use string[] instead of IEnumerable<string> in column names (#2815)
1 parent 86d5dda commit c2fabb8

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

docs/samples/Microsoft.ML.Samples/Dynamic/TextTransform.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ public static void Example()
3131

3232
// Another pipeline, that customizes the advanced settings of the FeaturizeText transformer.
3333
string customizedColumnName = "CustomizedTextFeatures";
34-
var customized_pipeline = ml.Transforms.Text.FeaturizeText(customizedColumnName, new List<string> { "SentimentText" },
35-
new TextFeaturizingEstimator.Options {
36-
KeepPunctuations = false,
37-
KeepNumbers = false,
38-
OutputTokens = true,
39-
TextLanguage = TextFeaturizingEstimator.Language.English, // supports English, French, German, Dutch, Italian, Spanish, Japanese
40-
});
34+
var customized_pipeline = ml.Transforms.Text.FeaturizeText(customizedColumnName, new TextFeaturizingEstimator.Options
35+
{
36+
KeepPunctuations = false,
37+
KeepNumbers = false,
38+
OutputTokens = true,
39+
TextLanguage = TextFeaturizingEstimator.Language.English, // supports English, French, German, Dutch, Italian, Spanish, Japanese
40+
}, "SentimentText");
4141

4242
// The transformed data for both pipelines.
4343
var transformedData_default = default_pipeline.Fit(trainData).Transform(trainData);

src/Microsoft.ML.Transforms/Text/TextCatalog.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public static TextFeaturizingEstimator FeaturizeText(this TransformsCatalog.Text
3434
/// </summary>
3535
/// <param name="catalog">The text-related transform's catalog.</param>
3636
/// <param name="outputColumnName">Name of the column resulting from the transformation of <paramref name="inputColumnNames"/>.</param>
37-
/// <param name="inputColumnNames">Name of the columns to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
3837
/// <param name="options">Advanced options to the algorithm.</param>
38+
/// <param name="inputColumnNames">Name of the columns to transform. If set to <see langword="null"/>, the value of the <paramref name="outputColumnName"/> will be used as source.</param>
3939
/// <example>
4040
/// <format type="text/markdown">
4141
/// <![CDATA[
@@ -45,8 +45,8 @@ public static TextFeaturizingEstimator FeaturizeText(this TransformsCatalog.Text
4545
/// </example>
4646
public static TextFeaturizingEstimator FeaturizeText(this TransformsCatalog.TextTransforms catalog,
4747
string outputColumnName,
48-
IEnumerable<string> inputColumnNames,
49-
TextFeaturizingEstimator.Options options)
48+
TextFeaturizingEstimator.Options options,
49+
params string[] inputColumnNames)
5050
=> new TextFeaturizingEstimator(Contracts.CheckRef(catalog, nameof(catalog)).GetEnvironment(),
5151
outputColumnName, inputColumnNames, options);
5252

test/Microsoft.ML.Benchmarks/StochasticDualCoordinateAscentClassifierBench.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ public void TrainSentiment()
9393
};
9494

9595
var loader = mlContext.Data.LoadFromTextFile(_sentimentDataPath, arguments);
96-
var text = mlContext.Transforms.Text.FeaturizeText("WordEmbeddings", new List<string> { "SentimentText" },
97-
new TextFeaturizingEstimator.Options {
98-
OutputTokens = true,
99-
KeepPunctuations = false,
100-
UseStopRemover = true,
101-
VectorNormalizer = TextFeaturizingEstimator.TextNormKind.None,
102-
UseCharExtractor = false,
103-
UseWordExtractor = false,
104-
}).Fit(loader).Transform(loader);
96+
var text = mlContext.Transforms.Text.FeaturizeText("WordEmbeddings", new TextFeaturizingEstimator.Options
97+
{
98+
OutputTokens = true,
99+
KeepPunctuations = false,
100+
UseStopRemover = true,
101+
VectorNormalizer = TextFeaturizingEstimator.TextNormKind.None,
102+
UseCharExtractor = false,
103+
UseWordExtractor = false,
104+
}, "SentimentText").Fit(loader).Transform(loader);
105105

106106
var trans = mlContext.Transforms.Text.ExtractWordEmbeddings("Features", "WordEmbeddings_TransformedText",
107107
WordEmbeddingsExtractingEstimator.PretrainedModelKind.Sswe).Fit(text).Transform(text);

test/Microsoft.ML.Tests/Scenarios/Api/Estimators/Visibility.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ void Visibility()
2525
{
2626
var ml = new MLContext(seed: 1, conc: 1);
2727
var pipeline = ml.Data.CreateTextLoader(TestDatasets.Sentiment.GetLoaderColumns(), hasHeader: true)
28-
.Append(ml.Transforms.Text.FeaturizeText("Features", new List<string> { "SentimentText" },
29-
new Transforms.Text.TextFeaturizingEstimator.Options { OutputTokens = true }));
28+
.Append(ml.Transforms.Text.FeaturizeText(
29+
"Features", new Transforms.Text.TextFeaturizingEstimator.Options { OutputTokens = true }, "SentimentText"));
3030

3131
var src = new MultiFileSource(GetDataPath(TestDatasets.Sentiment.trainFilename));
3232
var data = pipeline.Fit(src).Load(src);

0 commit comments

Comments
 (0)