Exemplo n.º 1
0
        internal static DeepstackResult DeserializeDeepstackResult(JsonElement element)
        {
            string              query            = default;
            Optional <string>   detectedLanguage = default;
            DeepstackPrediction prediction       = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("query"))
                {
                    query = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("detectedLanguage"))
                {
                    detectedLanguage = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("prediction"))
                {
                    prediction = DeepstackPrediction.DeserializeDeepstackPrediction(property.Value);
                    continue;
                }
            }
            return(new DeepstackResult(query, detectedLanguage.Value, prediction));
        }
        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 DeepstackResult(string query, DeepstackPrediction prediction)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (prediction == null)
            {
                throw new ArgumentNullException(nameof(prediction));
            }

            Query      = query;
            Prediction = prediction;
        }
Exemplo n.º 4
0
 public static DeepstackResult DeepstackResult(string query = null, string detectedLanguage = null, DeepstackPrediction prediction = null)
 {
     return(new DeepstackResult(query, detectedLanguage, prediction));
 }
 internal DeepstackResult(string query, string detectedLanguage, DeepstackPrediction prediction)
 {
     Query            = query;
     DetectedLanguage = detectedLanguage;
     Prediction       = prediction;
 }