srowen commented on a change in pull request #26480: [SPARK-29808][ML][PYTHON]
StopWordsRemover should support multi-cols
URL: https://github.com/apache/spark/pull/26480#discussion_r345221240
##########
File path:
mllib/src/test/scala/org/apache/spark/ml/feature/StopWordsRemoverSuite.scala
##########
@@ -217,4 +225,123 @@ class StopWordsRemoverSuite extends MLTest with
DefaultReadWriteTest {
Locale.setDefault(oldDefault)
}
}
+
+ test("Multiple Columns: StopWordsRemover default") {
+ val remover = new StopWordsRemover()
+ .setInputCols(Array("raw1", "raw2"))
+ .setOutputCols(Array("filtered1", "filtered2"))
+ val df = Seq(
+ (Seq("test", "test"), Seq("test1", "test2"), Seq("test", "test"),
Seq("test1", "test2")),
+ (Seq("a", "b", "c", "d"), Seq("a", "b"), Seq("b", "c", "d"), Seq("b")),
+ (Seq("a", "the", "an"), Seq("the", "an"), Seq(), Seq()),
+ (Seq("A", "The", "AN"), Seq("A", "The"), Seq(), Seq()),
+ (Seq(null), Seq(null), Seq(null), Seq(null)),
+ (Seq(), Seq(), Seq(), Seq())
+ ).toDF("raw1", "raw2", "expected1", "expected2")
+
+ remover.transform(df)
+ .select("filtered1", "expected1", "filtered2", "expected2")
+ .collect().foreach {
+ case Row(r1: Seq[String], e1: Seq[String], r2: Seq[String], e2:
Seq[String]) =>
Review comment:
Small nit: indent this more
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]