diff --git a/src/Microsoft.ML/Data/TextLoader.cs b/src/Microsoft.ML/Data/TextLoader.cs index 3c8550ef09..c9b16ad24e 100644 --- a/src/Microsoft.ML/Data/TextLoader.cs +++ b/src/Microsoft.ML/Data/TextLoader.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using Microsoft.CSharp; using Microsoft.ML.Runtime; using Microsoft.ML.Runtime.Api; using Microsoft.ML.Runtime.Data; @@ -84,8 +85,6 @@ public TextLoader CreateFrom(bool useHeader = false, $"Valid characters are 0-9, *, - and ~"); var name = mappingAttr.Name ?? field.Name; - if (name.Any(c => !Char.IsLetterOrDigit(c))) - throw Contracts.Except($"{name} is not alphanumeric."); Runtime.Data.TextLoader.Range[] sources; if (!Runtime.Data.TextLoader.Column.TryParseSourceEx(mappingAttr.Ordinal, out sources)) diff --git a/test/Microsoft.ML.Tests/TextLoaderTests.cs b/test/Microsoft.ML.Tests/TextLoaderTests.cs index 40c0b6525f..61a1744dfb 100644 --- a/test/Microsoft.ML.Tests/TextLoaderTests.cs +++ b/test/Microsoft.ML.Tests/TextLoaderTests.cs @@ -32,8 +32,11 @@ public void ConstructorDoesntThrow() Assert.NotNull(new Data.TextLoader("fakeFile.txt").CreateFrom(useHeader: false, supportSparse: false, trimWhitespace: false)); Assert.NotNull(new Data.TextLoader("fakeFile.txt").CreateFrom(useHeader: false, supportSparse: false)); Assert.NotNull(new Data.TextLoader("fakeFile.txt").CreateFrom(useHeader: false, allowQuotedStrings: false)); + + Assert.NotNull(new Data.TextLoader("fakeFile.txt").CreateFrom()); } + [Fact] public void CanSuccessfullyApplyATransform() { @@ -264,6 +267,15 @@ public class Input public float Number1; } + public class InputWithUnderscore + { + [Column("0")] + public string String_1; + + [Column("1")] + public float Number_1; + } + public class ModelWithoutColumnAttribute { public string String1;