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

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
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.