AI-102: Microsoft Azure AI Solution

Key Phrases

Question

Review the code snippet given below and choose two statements that are true.

static void ExampleCode(TextAnalyticsClient client) { var response = client.ExtractKeyPhrases("Enjoy sunny days in the winter weather"); Console.WriteLine('Key phrases:'); foreach (string keyphrase in response.Value) { Console.WriteLine($"{keyphrase}"); } } 

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answers: C and D.

Option A is not true because keyphrase extraction provides the main talking points.

“In”, “the” will not be displayed on the console.

Option B is not true because the sentiment level of the sentence is provided by the AnalyzeSentiment() function.

Option C is true.

<Response<KeyPhraseCollection> object will contain the list of detected key phrases.

Option D is true.

The code will display the key phrases from the input string onto the console.

The examples are “weather”, “sunny days”.

To learn more about keyphrase extraction example, use the link given below:

The given code snippet is using the Text Analytics service of Azure Cognitive Services to extract key phrases from a given input string. The code accepts a TextAnalyticsClient object and uses its ExtractKeyPhrases method to extract the key phrases from the input string "Enjoy sunny days in the winter weather". The key phrases are then printed onto the console using a foreach loop.

Now, let's evaluate the given statements to determine their validity:

A. The output will contain the words “Enjoy”, “sunny”, “days”, “in”, “the”, “winter”, “weather”. This statement is not entirely true. The code will extract key phrases from the input string and print them onto the console, but it won't print each word of the input string. The extracted key phrases will be based on the meaning and context of the input string. So, we cannot say for sure which words will be present in the output.

B. The sentence sentiment level would be displayed in the output. This statement is false. The code is only extracting key phrases from the input string and not determining its sentiment level. Therefore, the sentence sentiment level won't be displayed in the output.

C. <Response<KeyPhraseCollection> object will contain the list of detected key phrases. This statement is true. The response variable in the code snippet is of type Response<KeyPhraseCollection>, which means it will contain the list of detected key phrases returned by the ExtractKeyPhrases method.

D. The code will display the key phrases from input string onto the console. This statement is true. The code will extract key phrases from the input string using the Text Analytics service and display them on the console using a foreach loop.

So, the correct answers are C and D.