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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors