Learn how to implement multilingual chatbot functionality in C# using Azure AI Language Service. Discover the correct function call for detecting input text language.
Table of Contents
Question
You have been hired as an AI application developer for Xerigon Corporation. Your organization is developing a multilingual chatbot that can interact with customers in various languages. The chatbot needs to automatically detect the language of the user’s input text to respond appropriately or route the query to the right language-specific support agent.
You have been tasked with implementing this functionality in your C# application using the Azure AI Language service.
Complete the following C# code with the correct function call to detect the language of the input text:
using Azure; using Azure.AI.TextAnalytics; using System; namespace LanguageDetectionApp { class Program { static void Main(string[] args) { string endpoint = "myendpoint"; string apiKey = "<your-api-key>"; var client = new TextAnalyticsClient(new Uri(endpoint), new AzureKeyCredential(apiKey)); string document = "Bonjour, je voudrais savoir plus d'informations sur votre service."; // Add the correct function call to detect the language var response = client.MISSING(document); Console.WriteLine($"Detected Language: {response.Value.Name}"); } } }
A. Detect_Language
B. LanguageDetection
C. Analyze
D. DetectLanguage
Answer
D. DetectLanguage
Explanation
DetectLanguage is the correct function call to use in the given scenario. C# uses this function for detecting the language of text. It analyzes the given text and returns the detected language along with a confidence score. This function is part of the Azure AI Text Analytics SDK for C#, and it is the appropriate method for language detection in a C# application.
Detect_Language is not the correct function call to use in the given scenario. The Detect_language function is part of the Python SDK for the Azure AI Language service. While it serves the same purpose of detecting the language of text, it is specific to Python and does not apply to C# code.
LanguageDetection is not the correct function call to use in the given scenario. When using the Azure AI Language service via REST API, you would use the LanguageDetection field in the JSON request to specify that you want to detect the language of the text. However, this is relevant only for REST API calls and not for C# code.
Analyze is not the correct function call to use in the given scenario. The Analyze function is used in JavaScript to perform language detection, among other tasks. It is part of the Azure AI SDK for JavaScript.
Microsoft Azure AI Engineer Associate AI-102 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Microsoft Azure AI Engineer Associate AI-102 exam and earn Microsoft Azure AI Engineer Associate AI-102 certification.