-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathContentModel.cs
83 lines (73 loc) · 2.55 KB
/
ContentModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// <auto-generated>
// Code generated by LUISGen ContentModel.json -cs Luis.ContentModel -o
// Tool github: https://github.com/microsoft/botbuilder-tools
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
namespace LUISBotSample
{
public partial class ContentModel: IRecognizerConvert
{
[JsonProperty("text")]
public string Text;
[JsonProperty("alteredText")]
public string AlteredText;
public enum Intent {
Greet,
Learning,
None
};
[JsonProperty("intents")]
public Dictionary<Intent, IntentScore> Intents;
public class _Entities
{
// Simple entities
public string[] TechInterests;
public string[] documentation;
public string[] samples;
// Built-in entities
public string[] personName;
// Instance
public class _Instance
{
public InstanceData[] TechInterests;
public InstanceData[] documentation;
public InstanceData[] personName;
public InstanceData[] samples;
}
[JsonProperty("$instance")]
public _Instance _instance;
}
[JsonProperty("entities")]
public _Entities Entities;
[JsonExtensionData(ReadData = true, WriteData = true)]
public IDictionary<string, object> Properties {get; set; }
public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<ContentModel>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}
public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
var max = 0.0;
foreach (var entry in Intents)
{
if (entry.Value.Score > max)
{
maxIntent = entry.Key;
max = entry.Value.Score.Value;
}
}
return (maxIntent, max);
}
}
}