Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. // <auto-generated>
  2. // Code generated by LUISGen .\MainIntents.json -cs Luis.MainIntents -o .
  3. // Tool github: https://github.com/microsoft/botbuilder-tools
  4. // Changes may cause incorrect behavior and will be lost if the code is
  5. // regenerated.
  6. // </auto-generated>
  7. using Newtonsoft.Json;
  8. using System.Collections.Generic;
  9. using Microsoft.Bot.Builder;
  10. using Microsoft.Bot.Builder.AI.Luis;
  11.  
  12. namespace myNamedBot.CognitiveModels
  13. {
  14.     public partial class MainIntents : IRecognizerConvert
  15.     {
  16.         public string Text;
  17.         public string AlteredText;
  18.         public enum Intent
  19.         {
  20.             PassportLost,
  21.             None
  22.         };
  23.         public Dictionary<Intent, IntentScore> Intents;
  24.  
  25.  
  26.         [JsonExtensionData(ReadData = true, WriteData = true)]
  27.         public IDictionary<string, object> Properties { get; set; }
  28.  
  29.         public void Convert(dynamic result)
  30.         {
  31.             var app = JsonConvert.DeserializeObject<MainIntents>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
  32.             Text = app.Text;
  33.             AlteredText = app.AlteredText;
  34.             Intents = app.Intents;
  35.             Properties = app.Properties;
  36.         }
  37.  
  38.         public (Intent intent, double score) TopIntent()
  39.         {
  40.             Intent maxIntent = Intent.None;
  41.             var max = 0.0;
  42.             foreach (var entry in Intents)
  43.             {
  44.                 if (entry.Value.Score > max)
  45.                 {
  46.                     maxIntent = entry.Key;
  47.                     max = entry.Value.Score.Value;
  48.                 }
  49.             }
  50.             return (maxIntent, max);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement