Esempio n. 1
0
        internal static KeyPhraseLROTask DeserializeKeyPhraseLROTask(JsonElement element)
        {
            Optional <KeyPhraseTaskParameters> parameters = default;
            AnalyzeTextLROTaskKind             kind       = default;
            Optional <string> taskName = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("parameters"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    parameters = KeyPhraseTaskParameters.DeserializeKeyPhraseTaskParameters(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = new AnalyzeTextLROTaskKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("taskName"))
                {
                    taskName = property.Value.GetString();
                    continue;
                }
            }
            return(new KeyPhraseLROTask(taskName.Value, kind, parameters.Value));
        }
        internal static AnalyzeTextLROTask DeserializeAnalyzeTextLROTask(JsonElement element)
        {
            if (element.TryGetProperty("kind", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "CustomEntityRecognition": return(CustomEntitiesLROTask.DeserializeCustomEntitiesLROTask(element));

                case "CustomMultiLabelClassification": return(CustomMultiLabelClassificationLROTask.DeserializeCustomMultiLabelClassificationLROTask(element));

                case "CustomSingleLabelClassification": return(CustomSingleLabelClassificationLROTask.DeserializeCustomSingleLabelClassificationLROTask(element));

                case "EntityLinking": return(EntityLinkingLROTask.DeserializeEntityLinkingLROTask(element));

                case "EntityRecognition": return(EntitiesLROTask.DeserializeEntitiesLROTask(element));

                case "ExtractiveSummarization": return(ExtractiveSummarizationLROTask.DeserializeExtractiveSummarizationLROTask(element));

                case "Healthcare": return(HealthcareLROTask.DeserializeHealthcareLROTask(element));

                case "KeyPhraseExtraction": return(KeyPhraseLROTask.DeserializeKeyPhraseLROTask(element));

                case "PiiEntityRecognition": return(PiiLROTask.DeserializePiiLROTask(element));

                case "SentimentAnalysis": return(SentimentAnalysisLROTask.DeserializeSentimentAnalysisLROTask(element));
                }
            }
            AnalyzeTextLROTaskKind kind     = default;
            Optional <string>      taskName = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = new AnalyzeTextLROTaskKind(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("taskName"))
                {
                    taskName = property.Value.GetString();
                    continue;
                }
            }
            return(new AnalyzeTextLROTask(taskName.Value, kind));
        }