internal static BasePrediction DeserializeBasePrediction(JsonElement element)
        {
            if (element.TryGetProperty("projectType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "workflow": return(WorkflowPrediction.DeserializeWorkflowPrediction(element));

                case "conversation": return(DeepstackPrediction.DeserializeDeepstackPrediction(element));
                }
            }
            ProjectKind       projectType = default;
            Optional <string> topIntent   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("projectType"))
                {
                    projectType = new ProjectKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("topIntent"))
                {
                    topIntent = property.Value.GetString();
                    continue;
                }
            }
            return(new BasePrediction(projectType, topIntent.Value));
        }
        internal static DeepstackPrediction DeserializeDeepstackPrediction(JsonElement element)
        {
            IReadOnlyList <DeepstackIntent> intents  = default;
            IReadOnlyList <DeepstackEntity> entities = default;
            ProjectKind       projectType            = default;
            Optional <string> topIntent = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("intents"))
                {
                    List <DeepstackIntent> array = new List <DeepstackIntent>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeepstackIntent.DeserializeDeepstackIntent(item));
                    }
                    intents = array;
                    continue;
                }
                if (property.NameEquals("entities"))
                {
                    List <DeepstackEntity> array = new List <DeepstackEntity>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeepstackEntity.DeserializeDeepstackEntity(item));
                    }
                    entities = array;
                    continue;
                }
                if (property.NameEquals("projectType"))
                {
                    projectType = new ProjectKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("topIntent"))
                {
                    topIntent = property.Value.GetString();
                    continue;
                }
            }
            return(new DeepstackPrediction(projectType, topIntent.Value, intents, entities));
        }
Ejemplo n.º 3
0
 internal DeepstackPrediction(ProjectKind projectKind, string topIntent, IReadOnlyList <DeepstackIntent> intents, IReadOnlyList <DeepstackEntity> entities) : base(projectKind, topIntent)
 {
     Intents     = intents;
     Entities    = entities;
     ProjectKind = projectKind;
 }
Ejemplo n.º 4
0
 internal WorkflowPrediction(ProjectKind projectKind, string topIntent, IReadOnlyDictionary <string, TargetIntentResult> intents) : base(projectKind, topIntent)
 {
     Intents     = intents;
     ProjectKind = projectKind;
 }
Ejemplo n.º 5
0
        public static WorkflowPrediction WorkflowPrediction(ProjectKind projectKind = default, string topIntent = null, IReadOnlyDictionary <string, TargetIntentResult> intents = null)
        {
            intents ??= new Dictionary <string, TargetIntentResult>();

            return(new WorkflowPrediction(projectKind, topIntent, intents));
        }
Ejemplo n.º 6
0
 public static BasePrediction BasePrediction(ProjectKind projectKind = default, string topIntent = null)
 {
     return(new BasePrediction(projectKind, topIntent));
 }