Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
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
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