static async Task RecognizeUserInput() { while (true) { // Read the text to recognize Console.WriteLine("Enter the text to recognize:"); string input = Console.ReadLine().Trim(); if (input.ToLower() == "exit") { // Close application if user types "exit" break; } else { if (input.Length > 0) { // Create client with SuscriptionKey and AzureRegion var client = new LuisRuntimeAPI(new ApiKeyServiceClientCredentials(SubscriptionKey)) { AzureRegion = AzureRegion }; // Predict var result = await client.Prediction.ResolveAsync(ApplicationId, input); // Print result var json = JsonConvert.SerializeObject(result, Formatting.Indented); Console.WriteLine(json); Console.WriteLine(); } } } }
/// <summary> /// Initializes a new instance of the <see cref="LuisRecognizer"/> class. /// </summary> /// <param name="application">The LUIS _application to use to recognize text.</param> /// <param name="predictionOptions">The LUIS prediction options to use.</param> /// <param name="includeApiResults">TRUE to include raw LUIS API response.</param> public LuisRecognizer(LuisApplication application, LuisPredictionOptions predictionOptions = null, bool includeApiResults = false) { _runtime = new LuisRuntimeAPI(new ApiKeyServiceClientCredentials(application.EndpointKey)) { AzureRegion = (AzureRegions)Enum.Parse(typeof(AzureRegions), application.AzureRegion), }; _application = application; _options = predictionOptions ?? new LuisPredictionOptions(); _includeApiResults = includeApiResults; }