示例#1
0
        public static ConversationPrediction ConversationPrediction(ProjectKind projectKind = default, string topIntent = null, IEnumerable <ConversationIntent> intents = null, IEnumerable <ConversationEntity> entities = null)
        {
            intents ??= new List <ConversationIntent>();
            entities ??= new List <ConversationEntity>();

            return(new ConversationPrediction(projectKind, topIntent, intents?.ToList(), entities?.ToList()));
        }
示例#2
0
        internal static OrchestrationPrediction DeserializeOrchestrationPrediction(JsonElement element)
        {
            IReadOnlyDictionary <string, TargetIntentResult> intents = default;
            ProjectKind       projectKind = default;
            Optional <string> topIntent   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("intents"))
                {
                    Dictionary <string, TargetIntentResult> dictionary = new Dictionary <string, TargetIntentResult>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, TargetIntentResult.DeserializeTargetIntentResult(property0.Value));
                    }
                    intents = dictionary;
                    continue;
                }
                if (property.NameEquals("projectKind"))
                {
                    projectKind = new ProjectKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("topIntent"))
                {
                    topIntent = property.Value.GetString();
                    continue;
                }
            }
            return(new OrchestrationPrediction(projectKind, topIntent.Value, intents));
        }
示例#3
0
        internal static BasePrediction DeserializeBasePrediction(JsonElement element)
        {
            if (element.TryGetProperty("projectKind", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "workflow": return(OrchestratorPrediction.DeserializeOrchestratorPrediction(element));

                case "conversation": return(ConversationPrediction.DeserializeConversationPrediction(element));
                }
            }
            ProjectKind       projectKind = default;
            Optional <string> topIntent   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("projectKind"))
                {
                    projectKind = new ProjectKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("topIntent"))
                {
                    topIntent = property.Value.GetString();
                    continue;
                }
            }
            return(new BasePrediction(projectKind, topIntent.Value));
        }
示例#4
0
        internal static ConversationPrediction DeserializeConversationPrediction(JsonElement element)
        {
            IReadOnlyList <ConversationIntent> intents  = default;
            IReadOnlyList <ConversationEntity> entities = default;
            ProjectKind       projectKind = default;
            Optional <string> topIntent   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("intents"))
                {
                    List <ConversationIntent> array = new List <ConversationIntent>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ConversationIntent.DeserializeConversationIntent(item));
                    }
                    intents = array;
                    continue;
                }
                if (property.NameEquals("entities"))
                {
                    List <ConversationEntity> array = new List <ConversationEntity>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ConversationEntity.DeserializeConversationEntity(item));
                    }
                    entities = array;
                    continue;
                }
                if (property.NameEquals("projectKind"))
                {
                    projectKind = new ProjectKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("topIntent"))
                {
                    topIntent = property.Value.GetString();
                    continue;
                }
            }
            return(new ConversationPrediction(projectKind, topIntent.Value, intents, entities));
        }
示例#5
0
 public static BasePrediction BasePrediction(ProjectKind projectKind = default, string topIntent = null)
 {
     return(new BasePrediction(projectKind, topIntent));
 }
示例#6
0
        public static OrchestratorPrediction OrchestratorPrediction(ProjectKind projectKind = default, string topIntent = null, IReadOnlyDictionary <string, TargetIntentResult> intents = null)
        {
            intents ??= new Dictionary <string, TargetIntentResult>();

            return(new OrchestratorPrediction(projectKind, topIntent, intents));
        }
示例#7
0
 internal OrchestratorPrediction(ProjectKind projectKind, string topIntent, IReadOnlyDictionary <string, TargetIntentResult> intents) : base(projectKind, topIntent)
 {
     Intents     = intents;
     ProjectKind = projectKind;
 }
示例#8
0
 internal ConversationPrediction(ProjectKind projectKind, string topIntent, IReadOnlyList <ConversationIntent> intents, IReadOnlyList <ConversationEntity> entities) : base(projectKind, topIntent)
 {
     Intents     = intents;
     Entities    = entities;
     ProjectKind = projectKind;
 }