azure-docs icon indicating copy to clipboard operation
azure-docs copied to clipboard

Cannot get the sample code to work in Synapse notebook

Open stevenhoward30 opened this issue 2 years ago • 1 comments

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 Traceback (most recent call last) in 7 8 # Run the Text Analytics service with options ----> 9 sentiment = (TextSentiment() 10 .setLinkedService(linked_service_name) 11 .setTextCol("text")

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.

stevenhoward30 avatar Dec 13 '22 22:12 stevenhoward30

@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!!

RohitMungi-MSFT avatar Dec 21 '22 07:12 RohitMungi-MSFT

fixed in https://github.com/MicrosoftDocs/azure-docs-pr/pull/239406 . This issue can be closed. @RohitMungi-MSFT @Naveenommi-MSFT

ruixinxu avatar May 30 '23 01:05 ruixinxu