|
| 1 | +// <auto-generated> |
| 2 | +// Code generated by luis:generate:cs |
| 3 | +// Tool github: https://github.com/microsoft/botframwork-cli |
| 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 | +namespace Luis |
| 12 | +{ |
| 13 | + public partial class FlightBooking: IRecognizerConvert |
| 14 | + { |
| 15 | + [JsonProperty("text")] |
| 16 | + public string Text; |
| 17 | + |
| 18 | + [JsonProperty("alteredText")] |
| 19 | + public string AlteredText; |
| 20 | + |
| 21 | + public enum Intent { |
| 22 | + BookFlight, |
| 23 | + Cancel, |
| 24 | + GetWeather, |
| 25 | + None |
| 26 | + }; |
| 27 | + [JsonProperty("intents")] |
| 28 | + public Dictionary<Intent, IntentScore> Intents; |
| 29 | + |
| 30 | + public class _Entities |
| 31 | + { |
| 32 | + // Built-in entities |
| 33 | + public DateTimeSpec[] datetime; |
| 34 | + |
| 35 | + // Lists |
| 36 | + public string[][] Airport; |
| 37 | + |
| 38 | + |
| 39 | + // Composites |
| 40 | + public class _InstanceFrom |
| 41 | + { |
| 42 | + public InstanceData[] Airport; |
| 43 | + } |
| 44 | + public class FromClass |
| 45 | + { |
| 46 | + public string[][] Airport; |
| 47 | + [JsonProperty("$instance")] |
| 48 | + public _InstanceFrom _instance; |
| 49 | + } |
| 50 | + public FromClass[] From; |
| 51 | + |
| 52 | + public class _InstanceTo |
| 53 | + { |
| 54 | + public InstanceData[] Airport; |
| 55 | + } |
| 56 | + public class ToClass |
| 57 | + { |
| 58 | + public string[][] Airport; |
| 59 | + [JsonProperty("$instance")] |
| 60 | + public _InstanceTo _instance; |
| 61 | + } |
| 62 | + public ToClass[] To; |
| 63 | + |
| 64 | + // Instance |
| 65 | + public class _Instance |
| 66 | + { |
| 67 | + public InstanceData[] Airport; |
| 68 | + public InstanceData[] From; |
| 69 | + public InstanceData[] To; |
| 70 | + public InstanceData[] datetime; |
| 71 | + } |
| 72 | + [JsonProperty("$instance")] |
| 73 | + public _Instance _instance; |
| 74 | + } |
| 75 | + [JsonProperty("entities")] |
| 76 | + public _Entities Entities; |
| 77 | + |
| 78 | + [JsonExtensionData(ReadData = true, WriteData = true)] |
| 79 | + public IDictionary<string, object> Properties {get; set; } |
| 80 | + |
| 81 | + public void Convert(dynamic result) |
| 82 | + { |
| 83 | + var app = JsonConvert.DeserializeObject<FlightBooking>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); |
| 84 | + Text = app.Text; |
| 85 | + AlteredText = app.AlteredText; |
| 86 | + Intents = app.Intents; |
| 87 | + Entities = app.Entities; |
| 88 | + Properties = app.Properties; |
| 89 | + } |
| 90 | + |
| 91 | + public (Intent intent, double score) TopIntent() |
| 92 | + { |
| 93 | + Intent maxIntent = Intent.None; |
| 94 | + var max = 0.0; |
| 95 | + foreach (var entry in Intents) |
| 96 | + { |
| 97 | + if (entry.Value.Score > max) |
| 98 | + { |
| 99 | + maxIntent = entry.Key; |
| 100 | + max = entry.Value.Score.Value; |
| 101 | + } |
| 102 | + } |
| 103 | + return (maxIntent, max); |
| 104 | + } |
| 105 | + } |
| 106 | +} |
0 commit comments