示例#1
0
 internal DocumentLanguage(string id, DetectedLanguage detectedLanguage, IReadOnlyList <TextAnalyticsWarning> warnings, DocumentStatistics statistics)
 {
     Id = id;
     DetectedLanguage = detectedLanguage;
     Warnings         = warnings;
     Statistics       = statistics;
 }
示例#2
0
        internal DocumentLanguage(string id, DetectedLanguage detectedLanguage, IEnumerable <TextAnalyticsWarning> warnings)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (detectedLanguage == null)
            {
                throw new ArgumentNullException(nameof(detectedLanguage));
            }
            if (warnings == null)
            {
                throw new ArgumentNullException(nameof(warnings));
            }

            Id = id;
            DetectedLanguage = detectedLanguage;
            Warnings         = warnings.ToList();
        }
示例#3
0
        internal static DocumentLanguage DeserializeDocumentLanguage(JsonElement element)
        {
            string           id = default;
            DetectedLanguage detectedLanguage               = default;
            IReadOnlyList <TextAnalyticsWarning> warnings   = default;
            Optional <DocumentStatistics>        statistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("detectedLanguage"))
                {
                    detectedLanguage = DetectedLanguage.DeserializeDetectedLanguage(property.Value);
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarning> array = new List <TextAnalyticsWarning>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarning.DeserializeTextAnalyticsWarning(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = DocumentStatistics.DeserializeDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new DocumentLanguage(id, detectedLanguage, warnings, statistics.Value));
        }