Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Error in Sentiment Analysis - Azure

Hello world.

 

I am using Azure Cognitive Services API to analysis each customer answers in our NPS forms, and return Key Phrases, according to this tutorial and it is working fine.

 

I also want a Sentiment Analysis score, and so I created another custom function to measure this, like the tutorial says:

 

(text) => let
    apikey      = "<MY_KEY>",
    endpoint    = "https://<MY_DENTPOINT_DOMAIN>.cognitiveservices.azure.com/" & "/text/analytics/v3.0/sentiment",
    jsontext    = Text.FromBinary(Json.FromValue(Text.Start(Text.Trim(text), 5000))),
    jsonbody    = "{ documents: [ { language: ""pt-br"", id: ""0"", text: " & jsontext & " } ] }",
    bytesbody   = Text.ToBinary(jsonbody),
    headers     = [#"Ocp-Apim-Subscription-Key" = apikey],
    bytesresp   = Web.Contents(endpoint, [Headers=headers, Content=bytesbody]),
    jsonresp    = Json.Document(bytesresp),
    sentiment   = jsonresp[documents]{0}[detectedLanguage][confidenceScore]
    in  sentiment

 

 

And all I got is errors like this:

 

Erro na consulta ‘’. Expression.Error: O campo 'detectedLanguage' do registro não foi encontrado.
Detalhes:
    id=0
    sentiment=positive
    confidenceScores=
        positive=0,99
        neutral=0,01
        negative=0
    sentences=[List]
    warnings=[List]

 

 

What could I do?

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

A similar thread may help:

https://community.powerbi.com/t5/Desktop/Error-in-Azure-Sentiment-Analysis/td-p/1750742

 

You could also check the reference if needed.

https://docs.microsoft.com/en-us/rest/api/cognitiveservices-textanalytics/3.0/sentiment/sentiment

 


Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
PunchBird
Helper V
Helper V

Hi @Anonymous ,

The devil is in the detail. There is an error in the custom function you created (it's actually incorrect in the tutorial). 

It should be [confidenceScores] instead of [confidenceScore], so:

sentiment   = jsonresp[documents]{0}[detectedLanguage][confidenceScores]

 

v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

A similar thread may help:

https://community.powerbi.com/t5/Desktop/Error-in-Azure-Sentiment-Analysis/td-p/1750742

 

You could also check the reference if needed.

https://docs.microsoft.com/en-us/rest/api/cognitiveservices-textanalytics/3.0/sentiment/sentiment

 


Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors