Github user MLnick commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17451#discussion_r108359620
  
    --- Diff: python/pyspark/ml/tests.py ---
    @@ -389,6 +389,21 @@ def test_word2vec_param(self):
             # Check windowSize is set properly
             self.assertEqual(model.getWindowSize(), 6)
     
    +    def test_findSynonyms(self):
    +        sent = ("a b " * 100 + "a c " * 10).split(" ")
    +        doc = spark.createDataFrame([(sent,), (sent,)], ["sentence"])
    +        word2Vec = Word2Vec(vectorSize=5, seed=42, inputCol="sentence", 
outputCol="model")
    +        model = word2Vec.fit(doc)
    +        model.getVectors().show()
    +
    +        from pyspark.sql.functions import format_number as fmt
    +        from pyspark.ml.linalg import Vector
    +        from pyspark.ml.linalg import Vectors
    +        model.findSynonyms("a", 2).select("word", fmt("similarity", 
5).alias("similarity")).show()
    +
    +        # model.findSynonymsArray(["a"], 2).select("word", 
fmt("similarity", 5).alias("similarity")).show()
    +        model.findSynonymsArray(Vectors.dense("a"), 2).select("word", 
fmt("similarity", 5).alias("similarity")).show()
    --- End diff --
    
    As per style tests this line is too long. Also why are you creating a 
vector of "a"?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to