Github user keypointt commented on the issue:
https://github.com/apache/spark/pull/17451
I add a helper function findSynonymsTuple()
but in python terminal, I don't know how to access the tuple, could you
please help here? thanks a lot @holdenk
```
>>> from pyspark.ml.feature import Word2Vec
>>> 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)
>>> a = model.findSynonymsTuple("a", 2)
{'_auto_field': False,
'_field_names': set([]),
'_fully_populated': False,
'_gateway_client': <py4j.java_gateway.GatewayClient object at 0x11099a290>,
'_gateway_doc': None,
'_methods': {'getClass': <py4j.java_gateway.JavaMember object at
0x11115df90>},
'_target_id': u'o76'}
>>> a._1
<py4j.java_gateway.JavaMember object at 0x10f73ed10>
>>> print a._1
<py4j.java_gateway.JavaMember object at 0x10f73ed10>
>>> a._1[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'JavaMember' object does not support indexing
>>> a._1.get(0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'JavaMember' object has no attribute 'get'
```
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]