From d2e03083d7b2e5892b442ea8a80510db25f54c21 Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sun, 11 Oct 2020 12:04:30 +0530 Subject: [PATCH 01/12] Add NGram class --- .../Microsoft.Spark/ML/Feature/NGram.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/csharp/Microsoft.Spark/ML/Feature/NGram.cs diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs new file mode 100644 index 000000000..09e62131a --- /dev/null +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -0,0 +1,24 @@ +using Microsoft.Spark.Interop.Ipc; + +namespace Microsoft.Spark.ML.Feature +{ + public class NGram : FeatureBase, IJvmObjectReferenceProvider + { + private static readonly string s_NGramClassName = + "org.apache.spark.ml.feature.NGram"; + + public NGram() : base(s_NGramClassName) + { + } + + public NGram(string uid) : base(s_NGramClassName, uid) + { + } + + internal NGram(JvmObjectReference jvmObject) : base(jvmObject) + { + } + + JvmObjectReference IJvmObjectReferenceProvider.Reference => _jvmObject; + } +} From 7c43861d796bdea0faf50ee802b643f30ffe4943 Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sun, 11 Oct 2020 12:40:57 +0530 Subject: [PATCH 02/12] Update NGram with add functions to support sprak n-gram class --- .../Microsoft.Spark/ML/Feature/NGram.cs | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index 09e62131a..97173d215 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -1,16 +1,35 @@ +// 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 Microsoft.Spark.Interop; using Microsoft.Spark.Interop.Ipc; +using Microsoft.Spark.Sql; namespace Microsoft.Spark.ML.Feature { + /// + /// Class transformer that converts the input array of strings into an array of n-grams. + /// Null values in the input array are ignored. + /// It returns an array of n-grams where each n-gram is represented by a space-separated string of words. + /// public class NGram : FeatureBase, IJvmObjectReferenceProvider { private static readonly string s_NGramClassName = "org.apache.spark.ml.feature.NGram"; + /// + /// Create a without any parameters + /// public NGram() : base(s_NGramClassName) { } + /// + /// Create a with a UID that is used to give the + /// a unique ID + /// + /// An immutable unique ID for the object and its derivatives. public NGram(string uid) : base(s_NGramClassName, uid) { } @@ -20,5 +39,76 @@ internal NGram(JvmObjectReference jvmObject) : base(jvmObject) } JvmObjectReference IJvmObjectReferenceProvider.Reference => _jvmObject; + + /// + /// Gets the column that the should read from + /// + /// string, input column + public string GetInputCol() => (string)(_jvmObject.Invoke("getInputCol")); + + /// + /// Sets the column that the should read from + /// + /// The name of the column to as the source + /// New object + public NGram SetInputCol(string value) => + WrapAsNGram(_jvmObject.Invoke("setInputCol", value)); + + /// + /// The will create a new column in the DataFrame, this is the + /// name of the new column. + /// + /// string, the output column + public string GetOutputCol() => (string)(_jvmObject.Invoke("getOutputCol")); + + /// + /// The will create a new column in the DataFrame, this is the + /// name of the new column. + /// + /// The name of the new column + /// New object + public NGram SetOutputCol(string value) => + WrapAsNGram(_jvmObject.Invoke("setOutputCol", value)); + + /// + /// Gets N value for + /// + /// string, N value + public int GetN() => (int)(_jvmObject.Invoke("getN")); + + /// + /// Sets N value for + /// + /// N value + /// New object + public NGram SetN(int value) => + WrapAsNGram(_jvmObject.Invoke("setN", value)); + + /// + /// Executes the and transforms the DataFrame to include the new + /// column + /// + /// The DataFrame to transform + /// + /// New object with the source transformed + /// + public DataFrame Transform(DataFrame source) => + new DataFrame((JvmObjectReference)_jvmObject.Invoke("transform", source)); + + /// + /// Loads the that was previously saved using Save + /// + /// The path the previous was saved to + /// New object, loaded from path + public static NGram Load(string path) + { + return WrapAsNGram( + SparkEnvironment.JvmBridge.CallStaticJavaMethod( + s_NGramClassName, "load", path)); + } + + + private static NGram WrapAsNGram(object obj) => + new NGram((JvmObjectReference)obj); } } From 54493796a2273d5b37b0cb4884036e79e510a093 Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sun, 11 Oct 2020 12:47:46 +0530 Subject: [PATCH 03/12] Add tests suite for NGram --- .../IpcTests/ML/Feature/NGramTests.cs | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs diff --git a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs new file mode 100644 index 000000000..41173b37d --- /dev/null +++ b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs @@ -0,0 +1,55 @@ +using System.IO; +using Microsoft.Spark.ML.Feature; +using Microsoft.Spark.Sql; +using Microsoft.Spark.UnitTest.TestUtils; +using Xunit; + +namespace Microsoft.Spark.E2ETest.IpcTests.ML.Feature +{ + [Collection("Spark E2E Tests")] + public class NGramTests : FeatureBaseTests + { + private readonly SparkSession _spark; + + public NGramTests(SparkFixture fixture) : base(fixture) + { + _spark = fixture.Spark; + } + + [Fact] + public void TestNGram() + { + var expectedUid = "theUid"; + var expectedInputCol = "input_col"; + var expectedOutputCol = "output_col"; + var expectedN = 2; + + DataFrame input = _spark.Sql("SELECT split('Hi I heard about Spark', ' ') as input_col"); + + var nGram = new NGram(expectedUid) + .SetInputCol(expectedInputCol) + .SetOutputCol(expectedOutputCol) + .SetN(expectedN); + + var output = nGram.Transform(input); + + Assert.Contains(output.Schema().Fields, (f => f.Name == expectedOutputCol)); + Assert.Equal(expectedInputCol, nGram.GetInputCol()); + Assert.Equal(expectedOutputCol, nGram.GetOutputCol()); + Assert.Equal(expectedN, nGram.GetN()); + + using (var tempDirectory = new TemporaryDirectory()) + { + string savePath = Path.Join(tempDirectory.Path, "NGram"); + nGram.Save(savePath); + + var loadedNGram = NGram.Load(savePath); + Assert.Equal(nGram.Uid(), loadedNGram.Uid()); + } + + Assert.Equal(expectedUid, nGram.Uid()); + + TestFeatureBase(nGram, "inputCol", "input_col"); + } + } +} From 9910576d546c36359aab3705122a3b2ea9528f1b Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sat, 5 Dec 2020 19:41:04 +0530 Subject: [PATCH 04/12] Fix commenting issues. --- .../IpcTests/ML/Feature/NGramTests.cs | 26 +++++++++----- .../Microsoft.Spark/ML/Feature/NGram.cs | 35 +++++++++---------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs index 41173b37d..a03c732f5 100644 --- a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs +++ b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs @@ -1,3 +1,7 @@ +// 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.IO; using Microsoft.Spark.ML.Feature; using Microsoft.Spark.Sql; @@ -6,6 +10,9 @@ namespace Microsoft.Spark.E2ETest.IpcTests.ML.Feature { + /// + /// Test suite for class. + /// [Collection("Spark E2E Tests")] public class NGramTests : FeatureBaseTests { @@ -16,34 +23,37 @@ public NGramTests(SparkFixture fixture) : base(fixture) _spark = fixture.Spark; } + /// + /// Test case to test the methods in class. + /// [Fact] public void TestNGram() { - var expectedUid = "theUid"; - var expectedInputCol = "input_col"; - var expectedOutputCol = "output_col"; - var expectedN = 2; + string expectedUid = "theUid"; + string expectedInputCol = "input_col"; + string expectedOutputCol = "output_col"; + int expectedN = 2; DataFrame input = _spark.Sql("SELECT split('Hi I heard about Spark', ' ') as input_col"); - var nGram = new NGram(expectedUid) + NGram nGram = new NGram(expectedUid) .SetInputCol(expectedInputCol) .SetOutputCol(expectedOutputCol) .SetN(expectedN); - var output = nGram.Transform(input); + DataFrame output = nGram.Transform(input); Assert.Contains(output.Schema().Fields, (f => f.Name == expectedOutputCol)); Assert.Equal(expectedInputCol, nGram.GetInputCol()); Assert.Equal(expectedOutputCol, nGram.GetOutputCol()); Assert.Equal(expectedN, nGram.GetN()); - using (var tempDirectory = new TemporaryDirectory()) + using (TemporaryDirectory tempDirectory = new TemporaryDirectory()) { string savePath = Path.Join(tempDirectory.Path, "NGram"); nGram.Save(savePath); - var loadedNGram = NGram.Load(savePath); + NGram loadedNGram = NGram.Load(savePath); Assert.Equal(nGram.Uid(), loadedNGram.Uid()); } diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index 97173d215..a6f0e8544 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -9,9 +9,9 @@ namespace Microsoft.Spark.ML.Feature { /// - /// Class transformer that converts the input array of strings into an array of n-grams. - /// Null values in the input array are ignored. - /// It returns an array of n-grams where each n-gram is represented by a space-separated string of words. + /// Class transformer that converts the input array of strings into + /// an array of n-grams. Null values in the input array are ignored. It returns an array + /// of n-grams where each n-gram is represented by a space-separated string of words. /// public class NGram : FeatureBase, IJvmObjectReferenceProvider { @@ -19,7 +19,7 @@ public class NGram : FeatureBase, IJvmObjectReferenceProvider "org.apache.spark.ml.feature.NGram"; /// - /// Create a without any parameters + /// Create a without any parameters. /// public NGram() : base(s_NGramClassName) { @@ -27,9 +27,10 @@ public NGram() : base(s_NGramClassName) /// /// Create a with a UID that is used to give the - /// a unique ID + /// a unique ID. /// - /// An immutable unique ID for the object and its derivatives. + /// An immutable unique ID for the object and its derivatives. + /// public NGram(string uid) : base(s_NGramClassName, uid) { } @@ -41,13 +42,13 @@ internal NGram(JvmObjectReference jvmObject) : base(jvmObject) JvmObjectReference IJvmObjectReferenceProvider.Reference => _jvmObject; /// - /// Gets the column that the should read from + /// Gets the column that the should read from. /// /// string, input column public string GetInputCol() => (string)(_jvmObject.Invoke("getInputCol")); /// - /// Sets the column that the should read from + /// Sets the column that the should read from. /// /// The name of the column to as the source /// New object @@ -55,15 +56,13 @@ public NGram SetInputCol(string value) => WrapAsNGram(_jvmObject.Invoke("setInputCol", value)); /// - /// The will create a new column in the DataFrame, this is the - /// name of the new column. + /// Gets the output column that the writes. /// /// string, the output column - public string GetOutputCol() => (string)(_jvmObject.Invoke("getOutputCol")); + public string GetOutputCol() => (string)_jvmObject.Invoke("getOutputCol"); /// - /// The will create a new column in the DataFrame, this is the - /// name of the new column. + /// Sets the output column that the writes. /// /// The name of the new column /// New object @@ -71,13 +70,13 @@ public NGram SetOutputCol(string value) => WrapAsNGram(_jvmObject.Invoke("setOutputCol", value)); /// - /// Gets N value for + /// Gets N value for . /// /// string, N value - public int GetN() => (int)(_jvmObject.Invoke("getN")); + public int GetN() => (int)_jvmObject.Invoke("getN"); /// - /// Sets N value for + /// Sets N value for . /// /// N value /// New object @@ -86,7 +85,7 @@ public NGram SetN(int value) => /// /// Executes the and transforms the DataFrame to include the new - /// column + /// column. /// /// The DataFrame to transform /// @@ -96,7 +95,7 @@ public DataFrame Transform(DataFrame source) => new DataFrame((JvmObjectReference)_jvmObject.Invoke("transform", source)); /// - /// Loads the that was previously saved using Save + /// Loads the that was previously saved using Save. /// /// The path the previous was saved to /// New object, loaded from path From a49446b2f208d0546bb3abf7c0b0d4dd27eb1ecf Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sat, 5 Dec 2020 19:48:56 +0530 Subject: [PATCH 05/12] Add transform schema. --- .../IpcTests/ML/Feature/NGramTests.cs | 4 ++++ .../Microsoft.Spark/ML/Feature/NGram.cs | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs index a03c732f5..bfe4d0f1c 100644 --- a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs +++ b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs @@ -5,6 +5,7 @@ using System.IO; using Microsoft.Spark.ML.Feature; using Microsoft.Spark.Sql; +using Microsoft.Spark.Sql.Types; using Microsoft.Spark.UnitTest.TestUtils; using Xunit; @@ -41,9 +42,12 @@ public void TestNGram() .SetOutputCol(expectedOutputCol) .SetN(expectedN); + StructType outputSchema = nGram.TransformSchema(input.Schema()); + DataFrame output = nGram.Transform(input); Assert.Contains(output.Schema().Fields, (f => f.Name == expectedOutputCol)); + Assert.Contains(outputSchema.Fields, (f => f.Name == expectedOutputCol)); Assert.Equal(expectedInputCol, nGram.GetInputCol()); Assert.Equal(expectedOutputCol, nGram.GetOutputCol()); Assert.Equal(expectedN, nGram.GetN()); diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index a6f0e8544..9128dec8b 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -5,6 +5,7 @@ using Microsoft.Spark.Interop; using Microsoft.Spark.Interop.Ipc; using Microsoft.Spark.Sql; +using Microsoft.Spark.Sql.Types; namespace Microsoft.Spark.ML.Feature { @@ -94,6 +95,28 @@ public NGram SetN(int value) => public DataFrame Transform(DataFrame source) => new DataFrame((JvmObjectReference)_jvmObject.Invoke("transform", source)); + /// + /// Check transform validity and derive the output schema from the input schema. + /// + /// This checks for validity of interactions between parameters during Transform and + /// raises an exception if any parameter value is invalid. + /// + /// Typical implementation should first conduct verification on schema change and parameter + /// validity, including complex parameter interaction checks. + /// + /// + /// The of the which will be transformed. + /// + /// + /// The of the output schema that would have been derived from the + /// input schema, if Transform had been called. + /// + public StructType TransformSchema(StructType value) => + new StructType( + (JvmObjectReference)_jvmObject.Invoke( + "transformSchema", + DataType.FromJson(_jvmObject.Jvm, value.Json))); + /// /// Loads the that was previously saved using Save. /// From 87ebbb168b89002b31a2880dc92f129d01c4b00b Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sat, 5 Dec 2020 20:01:14 +0530 Subject: [PATCH 06/12] Fix formating issue --- src/csharp/Microsoft.Spark/ML/Feature/NGram.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index 9128dec8b..aafb90fe1 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -73,7 +73,7 @@ public NGram SetOutputCol(string value) => /// /// Gets N value for . /// - /// string, N value + /// int, N value public int GetN() => (int)_jvmObject.Invoke("getN"); /// @@ -122,12 +122,10 @@ public StructType TransformSchema(StructType value) => /// /// The path the previous was saved to /// New object, loaded from path - public static NGram Load(string path) - { - return WrapAsNGram( + public static NGram Load(string path) => + WrapAsNGram( SparkEnvironment.JvmBridge.CallStaticJavaMethod( s_NGramClassName, "load", path)); - } private static NGram WrapAsNGram(object obj) => From edf4bad7901662b61b22468a5ab505a179ad2615 Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sun, 6 Dec 2020 16:09:00 +0530 Subject: [PATCH 07/12] Channge type to var --- .../Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs index bfe4d0f1c..51616f4a3 100644 --- a/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs +++ b/src/csharp/Microsoft.Spark.E2ETest/IpcTests/ML/Feature/NGramTests.cs @@ -52,7 +52,7 @@ public void TestNGram() Assert.Equal(expectedOutputCol, nGram.GetOutputCol()); Assert.Equal(expectedN, nGram.GetN()); - using (TemporaryDirectory tempDirectory = new TemporaryDirectory()) + using (var tempDirectory = new TemporaryDirectory()) { string savePath = Path.Join(tempDirectory.Path, "NGram"); nGram.Save(savePath); From aaf69c5ef909249c71f7c32fdc3ae1bd05bda2a8 Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sun, 6 Dec 2020 16:25:18 +0530 Subject: [PATCH 08/12] Remove unwanted line break --- src/csharp/Microsoft.Spark/ML/Feature/NGram.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index aafb90fe1..d6dd2518b 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -46,15 +46,14 @@ internal NGram(JvmObjectReference jvmObject) : base(jvmObject) /// Gets the column that the should read from. /// /// string, input column - public string GetInputCol() => (string)(_jvmObject.Invoke("getInputCol")); + public string GetInputCol() => (string)_jvmObject.Invoke("getInputCol"); /// /// Sets the column that the should read from. /// /// The name of the column to as the source /// New object - public NGram SetInputCol(string value) => - WrapAsNGram(_jvmObject.Invoke("setInputCol", value)); + public NGram SetInputCol(string value) => WrapAsNGram(_jvmObject.Invoke("setInputCol", value)); /// /// Gets the output column that the writes. @@ -67,8 +66,7 @@ public NGram SetInputCol(string value) => /// /// The name of the new column /// New object - public NGram SetOutputCol(string value) => - WrapAsNGram(_jvmObject.Invoke("setOutputCol", value)); + public NGram SetOutputCol(string value) => WrapAsNGram(_jvmObject.Invoke("setOutputCol", value)); /// /// Gets N value for . @@ -81,8 +79,7 @@ public NGram SetOutputCol(string value) => /// /// N value /// New object - public NGram SetN(int value) => - WrapAsNGram(_jvmObject.Invoke("setN", value)); + public NGram SetN(int value) => WrapAsNGram(_jvmObject.Invoke("setN", value)); /// /// Executes the and transforms the DataFrame to include the new From 435c5f1cc3df2da9c494d9625717eeb4dfa9d7d0 Mon Sep 17 00:00:00 2001 From: Saravanakumar Date: Sat, 12 Dec 2020 18:43:21 +0530 Subject: [PATCH 09/12] Update src/csharp/Microsoft.Spark/ML/Feature/NGram.cs Co-authored-by: Niharika Dutta --- src/csharp/Microsoft.Spark/ML/Feature/NGram.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index d6dd2518b..a2d5d0853 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -122,7 +122,9 @@ public StructType TransformSchema(StructType value) => public static NGram Load(string path) => WrapAsNGram( SparkEnvironment.JvmBridge.CallStaticJavaMethod( - s_NGramClassName, "load", path)); + s_NGramClassName, + "load", + path)); private static NGram WrapAsNGram(object obj) => From 6326dad260b514fa160b5ac59999f3da9d89a079 Mon Sep 17 00:00:00 2001 From: Saravanakumar Date: Sat, 12 Dec 2020 18:43:30 +0530 Subject: [PATCH 10/12] Update src/csharp/Microsoft.Spark/ML/Feature/NGram.cs Co-authored-by: Niharika Dutta --- src/csharp/Microsoft.Spark/ML/Feature/NGram.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index a2d5d0853..378b790e6 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -127,7 +127,6 @@ public static NGram Load(string path) => path)); - private static NGram WrapAsNGram(object obj) => - new NGram((JvmObjectReference)obj); + private static NGram WrapAsNGram(object obj) => new NGram((JvmObjectReference)obj); } } From 8c969ddc7340de05cc5dee1658ca2eb0daad0e9e Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sat, 12 Dec 2020 18:46:10 +0530 Subject: [PATCH 11/12] Remove extra space --- src/csharp/Microsoft.Spark/ML/Feature/NGram.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index 378b790e6..4275740dc 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -125,8 +125,7 @@ public static NGram Load(string path) => s_NGramClassName, "load", path)); - - + private static NGram WrapAsNGram(object obj) => new NGram((JvmObjectReference)obj); } } From b2b97bf4033da0e29a74ea2b0960d52dc4ddc550 Mon Sep 17 00:00:00 2001 From: Saravana Kumar Date: Sun, 20 Dec 2020 19:05:28 +0530 Subject: [PATCH 12/12] Rename variable --- src/csharp/Microsoft.Spark/ML/Feature/NGram.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs index 4275740dc..2e49d52ff 100644 --- a/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs +++ b/src/csharp/Microsoft.Spark/ML/Feature/NGram.cs @@ -16,13 +16,13 @@ namespace Microsoft.Spark.ML.Feature /// public class NGram : FeatureBase, IJvmObjectReferenceProvider { - private static readonly string s_NGramClassName = + private static readonly string s_nGramClassName = "org.apache.spark.ml.feature.NGram"; /// /// Create a without any parameters. /// - public NGram() : base(s_NGramClassName) + public NGram() : base(s_nGramClassName) { } @@ -32,7 +32,7 @@ public NGram() : base(s_NGramClassName) /// /// An immutable unique ID for the object and its derivatives. /// - public NGram(string uid) : base(s_NGramClassName, uid) + public NGram(string uid) : base(s_nGramClassName, uid) { } @@ -87,7 +87,7 @@ internal NGram(JvmObjectReference jvmObject) : base(jvmObject) /// /// The DataFrame to transform /// - /// New object with the source transformed + /// New object with the source transformed. /// public DataFrame Transform(DataFrame source) => new DataFrame((JvmObjectReference)_jvmObject.Invoke("transform", source)); @@ -122,10 +122,10 @@ public StructType TransformSchema(StructType value) => public static NGram Load(string path) => WrapAsNGram( SparkEnvironment.JvmBridge.CallStaticJavaMethod( - s_NGramClassName, - "load", + s_nGramClassName, + "load", path)); - + private static NGram WrapAsNGram(object obj) => new NGram((JvmObjectReference)obj); } }