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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Text Analysis: There weren't enough elements in the enumeration to complete the operation.

Hi everybody,

I encountered a problem with Cognitive Services: Text Analysis.

I follow this document to get key phrases from text.

I use this code to bbuild the custom function:

// Returns key phrases from the text in a comma-separated list
(text) => let
    apikey      = "YOUR_API_KEY_HERE",
    endpoint    = "https://westus.api.cognitive.microsoft.com/text/analytics/v2.1/keyPhrases",
    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),
    keyphrases  = Text.Lower(Text.Combine(jsonresp[documents]{0}[keyPhrases], ", "))
in  keyphrases

It works OK as is (with language: ""en"") but I have the text in Czech so I need to chenge the language parameter to cs (which is ISO 6391 Name for Czech).

When I change it and I invoke the new column with function I get An error occurred in the ‘’ query. Expression.Error: There weren't enough elements in the enumeration to complete the operation.

When I chage language back to en it works OK but doesn't handle language correctly :-(.

Do you have any ideas?

Thank you.

1 ACCEPTED SOLUTION
d_gosbell
Super User
Super User

Unfortunately it does not look like Czech is listed as currently supported the Key Phrases api

https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support#language-l...

View solution in original post

2 REPLIES 2
d_gosbell
Super User
Super User

Unfortunately it does not look like Czech is listed as currently supported the Key Phrases api

https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/language-support#language-l...

Anonymous
Not applicable

OK, I didn't notice that document before.

Thank you, d_gosbell.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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