internal DocumentLanguage(string id, DetectedLanguageInternal detectedLanguage, IReadOnlyList <TextAnalyticsWarningInternal> warnings, TextDocumentStatistics?statistics)
 {
     Id = id;
     DetectedLanguage = detectedLanguage;
     Warnings         = warnings;
     Statistics       = statistics;
 }
Ejemplo n.º 2
0
        public LanguageDetectionDocumentResult(string id, IEnumerable <DocumentWarning> warnings, DetectedLanguageInternal detectedLanguage) : base(id, warnings)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (warnings == null)
            {
                throw new ArgumentNullException(nameof(warnings));
            }

            DetectedLanguage = detectedLanguage;
        }
        internal DocumentLanguage(string id, DetectedLanguageInternal detectedLanguage, IEnumerable <TextAnalyticsWarningInternal> warnings)
        {
            if (id == null)
            {
                throw new ArgumentNullException(nameof(id));
            }
            if (warnings == null)
            {
                throw new ArgumentNullException(nameof(warnings));
            }

            Id = id;
            DetectedLanguage = detectedLanguage;
            Warnings         = warnings.ToList();
        }
Ejemplo n.º 4
0
        internal static DocumentLanguage DeserializeDocumentLanguage(JsonElement element)
        {
            string id = default;
            DetectedLanguageInternal detectedLanguage               = default;
            IReadOnlyList <TextAnalyticsWarningInternal> warnings   = default;
            Optional <TextDocumentStatistics>            statistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("detectedLanguage"))
                {
                    detectedLanguage = DetectedLanguageInternal.DeserializeDetectedLanguageInternal(property.Value);
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new DocumentLanguage(id, detectedLanguage, warnings, Optional.ToNullable(statistics)));
        }
Ejemplo n.º 5
0
 internal LanguageDetectionDocumentResult(string id, IList <DocumentWarning> warnings, TextDocumentStatistics?statistics, DetectedLanguageInternal detectedLanguage) : base(id, warnings, statistics)
 {
     DetectedLanguage = detectedLanguage;
 }