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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Cmoore
Frequent Visitor

Azure Cognitive Services connection to Power BI

Hi,

 

I've just been granted access to Cognitive services in my organisation and want to use "Entity Recognition" to extract company entities from a headline text. For example, "text": "Eutelsat Downgraded to B by SP Outlook Stable." would extract Eutelsat as an organisation. I am wanting to connect Power BI to Cognitive services and have produced this bank of code;

 

(text) => let   

apikey      = "xxxxxxxxxxxxxx",    

endpoint    = "https://xxxxxxxxxxxx.cognitiveservices.azure.com/language/:analyze-text?api- version=2023-04-01",    

jsontext    = Text.FromBinary(Json.FromValue(Text.Start(Text.Trim(text), 5000))),    

jsonbody    = "{ documents: [ { language: ""en"", 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),    

doc=jsonresp[documents]{0},    

result=doc[entities]

in #"result"

When trialling the connections I saw that Entity recognition was classified as "kind": "EntityRecognition" in the body. Would you happen to know how I can connect to EntityRecognition language service and amend the code above? 

 

Thanks

Chris

2 REPLIES 2
v-yohua-msft
Community Support
Community Support

Hi, @Cmoore 

 

To connect to the EntityRecognition language service, you need to specify the kind parameter in your request body as EntityRecognition. This indicates that you are requesting the EntityRecognition language feature. You can also specify other input parameters, such as the language and the text to be analyzed by the Language service.

 

Perhaps you can use the following modification code to connect to the EntityRecognition language service:

 

(text) => let

    apikey = "xxxxxxxxxxxxxx",

    endpoint = https://xxxxxxxxxxxx.cognitiveservices.azure.com/language/:analyze-text?api-version=2023-04-01,

    jsontext = Text.FromBinary(Json.FromValue(Text.Start(Text.Trim(text), 5000))),

    jsonbody = "{ documents: [ { language: ""en"", id: ""0"", text: " & jsontext & " } ], kind: ""EntityRecognition"" }",

    bytesbody = Text.ToBinary(jsonbody),

    headers = [#"Ocp-Apim-Subscription-Key" = apikey],

    bytesresp = Web.Contents(endpoint, [Headers=headers, Content=bytesbody]),

    jsonresp = Json.Document(bytesresp),

    doc=jsonresp[documents]{0},

    result=doc[entities]

in #"result"

 

The kind parameter in the jsonbody variable is set to EntityRecognition. This might connect Power BI to the EntityRecognition language service and extract the corporate entity from the text provided.

 

How to Get Your Question Answered Quickly 

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you I will take a look. Over the weekend, I came across another end-point that is in use. Do you know the differences between; 

https://xxxxxxxxx.cognitiveservices.azure.com/text/analytics/v2.1/entities and

https://xxxxxxxxx.cognitiveservices.azure.com/text/analytics/v3.1/entities/recognition/general

 

Is there one instance that we should use over another? When I'm looking through the Microsoft documentation I never see any such end points mentioned.

 

Thanks

Chris

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors