Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Microsoft.ML.AutoML/CodeGen/estimator-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"SentenceSimilarity",
"ObjectDetection",
"QuestionAnswering",
"NamedEntityRecognition"
"NamedEntityRecognition",
"NormalizeText"
]
},
"nugetDependencies": {
Expand Down Expand Up @@ -114,7 +115,8 @@
"Microsoft.ML.Transforms.Image",
"Microsoft.ML.Trainers.FastTree",
"Microsoft.ML.TorchSharp",
"Microsoft.ML.Trainers.LightGbm"
"Microsoft.ML.Trainers.LightGbm",
"Microsoft.ML.Transforms.Text.TextNormalizingEstimator"
]
}
},
Expand Down Expand Up @@ -198,7 +200,11 @@
"scoreThreshold",
"steps",
"initLearningRate",
"weightDecay"
"weightDecay",
"mode",
"keepPunctuations",
"keepDiacritics",
"keepNumbers"
]
},
"argumentType": {
Expand Down
34 changes: 34 additions & 0 deletions src/Microsoft.ML.AutoML/CodeGen/normalize_text_search_space.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"$schema": "./search-space-schema.json#",
"name": "normalize_text_option",
"search_space": [
{
"name": "InputColumnName",
"type": "string"
},
{
"name": "OutputColumnName",
"type": "string"
},
{
"name": "Mode",
"type": "caseMode",
"default": "CaseMode.Lower"
},
{
"name": "KeepDiacritics",
"type": "boolean",
"default": false
},
{
"name": "KeepPunctuations",
"type": "boolean",
"default": true
},
{
"name": "KeepNumbers",
"type": "boolean",
"default": true
}
]
}
22 changes: 18 additions & 4 deletions src/Microsoft.ML.AutoML/CodeGen/search-space-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@
"DataKind.DateTimeOffset"
]
},
"caseMode": {
"type": "string",
"enum": [
"CaseMode.Lower",
"CaseMode.Upper",
"CaseMode.None"
]
},
"bertArchitectureArray": {
"type": "array",
"items": {
Expand All @@ -90,7 +98,7 @@
"$ref": "#/definitions/dnnModelFactoryArray"
},
{
"$ref": "#/definitions/imageClassificationArchArray"
"$ref": "#/definitions/imageClassificationArchArray"
},
{
"$ref": "#/definitions/boolArray"
Expand Down Expand Up @@ -168,7 +176,8 @@
"sentence_similarity_option",
"object_detection_option",
"question_answering_option",
"named_entity_recognition_option"
"named_entity_recognition_option",
"normalize_text_option"
]
},
"option_name": {
Expand Down Expand Up @@ -241,7 +250,11 @@
"TopKAnswers",
"TargetType",
"PredictionColumnName",
"KeyData"
"KeyData",
"Mode",
"KeepPunctuations",
"KeepDiacritics",
"KeepNumbers"
]
},
"option_type": {
Expand All @@ -261,7 +274,8 @@
"bertArchitecture",
"imageClassificationArchType",
"dataKind",
"dataView"
"dataView",
"caseMode"
]
}
},
Expand Down
33 changes: 33 additions & 0 deletions src/Microsoft.ML.AutoML/CodeGen/transformer-estimators.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,39 @@
"usingStatements": [ "Microsoft.ML", "Microsoft.ML.Data" ],
"searchOption": "featurize_text_option"
},
{
"functionName": "NormalizeText",
"estimatorTypes": [ "Text" ],
"arguments": [
{
"argumentName": "outputColumnName",
"argumentType": "string"
},
{
"argumentName": "inputColumnName",
"argumentType": "string"
},
{
"argumentName": "mode",
"argumentType": "caseMode"
},
{
"argumentName": "keepDiacritics",
"argumentType": "boolean"
},
{
"argumentName": "keepPunctuations",
"argumentType": "boolean"
},
{
"argumentName": "keepNumbers",
"argumentType": "boolean"
}
],
"nugetDependencies": [ "Microsoft.ML" ],
"usingStatements": [ "Microsoft.ML", "Microsoft.ML.Data", "Microsoft.ML.Transforms.Text.TextNormalizingEstimator"],
"searchOption": "normalize_text_option"
},
{
"functionName": "ConvertType",
"estimatorTypes": [ "Conversion" ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
{
"name": "KeyData",
"type": "dataView"
},
{
"name": "Mode",
"type": "caseMode"
}
]
}
5 changes: 4 additions & 1 deletion src/Microsoft.ML.AutoML/Microsoft.ML.AutoML.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<AdditionalFiles Include="CodeGen\code_gen_flag.json" />
<AdditionalFiles Include="CodeGen\*-estimators.json" />
</ItemGroup>
<ItemGroup>
<None Remove="CodeGen\normalize_text_search_space.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Tuner\Portfolios.json">
Expand All @@ -86,7 +89,7 @@
<!--The path needed to be hardcoded for this to work on our publishing CI-->
<BuildOutputInPackage Condition="Exists('$(PackageAssetsPath)$(PackageIdFolderName)\runtimes\win-x86\native\LdaNative.pdb')" Include="$(PackageAssetsPath)$(PackageIdFolderName)\runtimes\win-x86\native\LdaNative.pdb" TargetPath="..\..\runtimes\win-x86\native" />
<BuildOutputInPackage Condition="Exists('$(PackageAssetsPath)$(PackageIdFolderName)\runtimes\win-x64\native\LdaNative.pdb')" Include="$(PackageAssetsPath)$(PackageIdFolderName)\runtimes\win-x64\native\LdaNative.pdb" TargetPath="..\..\runtimes\win-x64\native" />
<BuildOutputInPackage Condition="Exists('$(PackageAssetsPath)$(PackageIdFolderName)\runtimes\win-arm64\native\LdaNative.pdb')" Include="$(PackageAssetsPath)$(PackageIdFolderName)\runtimes\win-arm64\native\LdaNative.pdb" TargetPath="..\..\runtimes\win-arm64\native"/>
<BuildOutputInPackage Condition="Exists('$(PackageAssetsPath)$(PackageIdFolderName)\runtimes\win-arm64\native\LdaNative.pdb')" Include="$(PackageAssetsPath)$(PackageIdFolderName)\runtimes\win-arm64\native\LdaNative.pdb" TargetPath="..\..\runtimes\win-arm64\native" />
</ItemGroup>
</Target>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.ML.AutoML.CodeGen
{
internal partial class NormalizeText
{
public override IEstimator<ITransformer> BuildFromOption(MLContext context, NormalizeTextOption param)
{
return context.Transforms.Text.NormalizeText(param.OutputColumnName, param.InputColumnName, param.Mode, param.KeepDiacritics, param.KeepPunctuations, param.KeepNumbers);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void Execute(GeneratorExecutionContext context)
"imageClassificationArchType" => "Microsoft.ML.Vision.ImageClassificationTrainer.Architecture",
"dataKind" => "Microsoft.ML.Data.DataKind",
"dataView" => "Microsoft.ML.IDataView",
"caseMode" => "Microsoft.ML.Transforms.Text.TextNormalizingEstimator.CaseMode",
_ => throw new ArgumentException("unknown type"),
};

Expand All @@ -78,6 +79,7 @@ public void Execute(GeneratorExecutionContext context)
(_, "Microsoft.ML.Vision.ImageClassificationTrainer.Architecture") => defaultToken.GetValue<string>(),
(_, "Microsoft.ML.Data.DataKind") => defaultToken.GetValue<string>(),
(_, "Microsoft.ML.IDataView") => defaultToken.GetValue<string>(),
(_, "Microsoft.ML.Transforms.Text.TextNormalizingEstimator.CaseMode") => defaultToken.GetValue<string>(),
(_, _) => throw new ArgumentException("unknown"),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public virtual string TransformText()
using BertArchitecture = Microsoft.ML.TorchSharp.NasBert.BertArchitecture;
using static Microsoft.ML.Vision.ImageClassificationTrainer.Architecture;
using DataKind = Microsoft.ML.Data.DataKind;
using CaseMode = Microsoft.ML.Transforms.Text.TextNormalizingEstimator.CaseMode;

#nullable enable

namespace ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ using Anchor = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Anchor;
using BertArchitecture = Microsoft.ML.TorchSharp.NasBert.BertArchitecture;
using static Microsoft.ML.Vision.ImageClassificationTrainer.Architecture;
using DataKind = Microsoft.ML.Data.DataKind;
using CaseMode = Microsoft.ML.Transforms.Text.TextNormalizingEstimator.CaseMode;

#nullable enable

namespace <#=NameSpace#>
Expand Down