azure-docs
azure-docs copied to clipboard
Cannot get the sample code to work in Synapse notebook
I'm trying to run Sentiment Analysis from Synapse. I can it easily in Azure Machine Learning, or Azure Databricks using azure.ai.textanalytics. However; the setup of this in Synapse seems overly difficult, so I was looking for a more straightforward way to do this. I came across this tutorial page so use synapse.ml. It looks like the way to pursue this.
I created the linked services to my cognitive services successfully. I'm able to execute the first two cells, but the third cell should be under the Text Sentiment header, and there, whether under V2, or V3.1, both of the cells produce an error that says:
AttributeError: 'TextSentiment' object has no attribute 'setLinkedService'
I'm stuck here. It seems that either something else is required that I can't see, or something has changed.
FWIW, I tried commenting this line out, but if I do, I get a whole set of errors in the last line that runs the display() method.
I'm stuck. Can you help, please?
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: f29451e5-b712-7198-2bc3-a4c6b6685143
- Version Independent ID: 6b6a93c2-c800-5f25-92d8-1768d233ebd0
- Content: Tutorial: Text Analytics with Cognitive Service - Azure Synapse Analytics
- Content Source: articles/synapse-analytics/machine-learning/tutorial-text-analytics-use-mmlspark.md
- Service: synapse-analytics
- Sub-service: machine-learning
- GitHub Login: @ruixinxu
- Microsoft Alias: ruxu
@stevenhoward30
Thanks for your feedback! We will investigate and update as appropriate.
@stevenhoward30 I think this document needs an update. The latest version 0.10.2 example, as mentioned below should work.
sentiment = (TextSentiment()
.setTextCol("text")
.setLocation("eastasia") # Set the location of your cognitive service
.setSubscriptionKey(cognitive_service_key)
.setOutputCol("sentiment")
.setErrorCol("error")
.setLanguageCol("language"))
Please see this page for details. @ruixinxu Could you please check and update this document as required? Thanks!!
fixed in https://github.com/MicrosoftDocs/azure-docs-pr/pull/239406 . This issue can be closed. @RohitMungi-MSFT @Naveenommi-MSFT