internal static EntityRecognitionSkill DeserializeEntityRecognitionSkill(JsonElement element)
        {
            IList <EntityCategory>         categories          = default;
            EntityRecognitionSkillLanguage?defaultLanguageCode = default;
            bool?  includeTypelessEntities = default;
            double?minimumPrecision        = default;
            string odataType   = default;
            string name        = default;
            string description = default;
            string context     = default;
            IList <InputFieldMappingEntry>  inputs  = default;
            IList <OutputFieldMappingEntry> outputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("categories"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <EntityCategory> array = new List <EntityCategory>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString().ToEntityCategory());
                    }
                    categories = array;
                    continue;
                }
                if (property.NameEquals("defaultLanguageCode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    defaultLanguageCode = new EntityRecognitionSkillLanguage(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("includeTypelessEntities"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    includeTypelessEntities = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("minimumPrecision"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    minimumPrecision = property.Value.GetDouble();
                    continue;
                }
                if (property.NameEquals("@odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("context"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    context = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <InputFieldMappingEntry> array = new List <InputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item));
                        }
                    }
                    inputs = array;
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    List <OutputFieldMappingEntry> array = new List <OutputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item));
                        }
                    }
                    outputs = array;
                    continue;
                }
            }
            return(new EntityRecognitionSkill(odataType, name, description, context, inputs, outputs, categories, defaultLanguageCode, includeTypelessEntities, minimumPrecision));
        }
        internal static Skill DeserializeSkill(JsonElement element)
        {
            if (element.TryGetProperty("@odata.type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Skills.Custom.WebApiSkill": return(WebApiSkill.DeserializeWebApiSkill(element));

                case "#Microsoft.Skills.Text.EntityRecognitionSkill": return(EntityRecognitionSkill.DeserializeEntityRecognitionSkill(element));

                case "#Microsoft.Skills.Text.KeyPhraseExtractionSkill": return(KeyPhraseExtractionSkill.DeserializeKeyPhraseExtractionSkill(element));

                case "#Microsoft.Skills.Text.LanguageDetectionSkill": return(LanguageDetectionSkill.DeserializeLanguageDetectionSkill(element));

                case "#Microsoft.Skills.Text.MergeSkill": return(MergeSkill.DeserializeMergeSkill(element));

                case "#Microsoft.Skills.Text.SentimentSkill": return(SentimentSkill.DeserializeSentimentSkill(element));

                case "#Microsoft.Skills.Text.SplitSkill": return(SplitSkill.DeserializeSplitSkill(element));

                case "#Microsoft.Skills.Text.TranslationSkill": return(TextTranslationSkill.DeserializeTextTranslationSkill(element));

                case "#Microsoft.Skills.Util.ConditionalSkill": return(ConditionalSkill.DeserializeConditionalSkill(element));

                case "#Microsoft.Skills.Util.ShaperSkill": return(ShaperSkill.DeserializeShaperSkill(element));

                case "#Microsoft.Skills.Vision.ImageAnalysisSkill": return(ImageAnalysisSkill.DeserializeImageAnalysisSkill(element));

                case "#Microsoft.Skills.Vision.OcrSkill": return(OcrSkill.DeserializeOcrSkill(element));
                }
            }
            string odataType   = default;
            string name        = default;
            string description = default;
            string context     = default;
            IList <InputFieldMappingEntry>  inputs  = default;
            IList <OutputFieldMappingEntry> outputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("context"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    context = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <InputFieldMappingEntry> array = new List <InputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item));
                        }
                    }
                    inputs = array;
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    List <OutputFieldMappingEntry> array = new List <OutputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item));
                        }
                    }
                    outputs = array;
                    continue;
                }
            }
            return(new Skill(odataType, name, description, context, inputs, outputs));
        }
Ejemplo n.º 3
0
        internal static LanguageDetectionSkill DeserializeLanguageDetectionSkill(JsonElement element)
        {
            string odataType   = default;
            string name        = default;
            string description = default;
            string context     = default;
            IList <InputFieldMappingEntry>  inputs  = default;
            IList <OutputFieldMappingEntry> outputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("context"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    context = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <InputFieldMappingEntry> array = new List <InputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item));
                        }
                    }
                    inputs = array;
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    List <OutputFieldMappingEntry> array = new List <OutputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item));
                        }
                    }
                    outputs = array;
                    continue;
                }
            }
            return(new LanguageDetectionSkill(odataType, name, description, context, inputs, outputs));
        }
Ejemplo n.º 4
0
        internal static OcrSkill DeserializeOcrSkill(JsonElement element)
        {
            TextExtractionAlgorithm?textExtractionAlgorithm = default;
            OcrSkillLanguage?       defaultLanguageCode     = default;
            bool?  detectOrientation = default;
            string odataType         = default;
            string name        = default;
            string description = default;
            string context     = default;
            IList <InputFieldMappingEntry>  inputs  = default;
            IList <OutputFieldMappingEntry> outputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("textExtractionAlgorithm"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    textExtractionAlgorithm = property.Value.GetString().ToTextExtractionAlgorithm();
                    continue;
                }
                if (property.NameEquals("defaultLanguageCode"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    defaultLanguageCode = new OcrSkillLanguage(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("detectOrientation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    detectOrientation = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("@odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("context"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    context = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <InputFieldMappingEntry> array = new List <InputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item));
                        }
                    }
                    inputs = array;
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    List <OutputFieldMappingEntry> array = new List <OutputFieldMappingEntry>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item));
                        }
                    }
                    outputs = array;
                    continue;
                }
            }
            return(new OcrSkill(odataType, name, description, context, inputs, outputs, textExtractionAlgorithm, defaultLanguageCode, detectOrientation));
        }