internal static KeyValuePair_internal DeserializeKeyValuePair_internal(JsonElement element) { KeyValuePair_internal result = new KeyValuePair_internal(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("label")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Label = property.Value.GetString(); continue; } if (property.NameEquals("key")) { result.Key = KeyValueElement_internal.DeserializeKeyValueElement_internal(property.Value); continue; } if (property.NameEquals("value")) { result.Value = KeyValueElement_internal.DeserializeKeyValueElement_internal(property.Value); continue; } if (property.NameEquals("confidence")) { result.Confidence = property.Value.GetSingle(); continue; } } return(result); }
internal FormField(string name, int pageNumber, KeyValuePair_internal field, IReadOnlyList <ReadResult_internal> readResults) { Confidence = field.Confidence; Name = name; BoundingBox labelBoundingBox = field.Key.BoundingBox == null ? default : new BoundingBox(field.Key.BoundingBox); IReadOnlyList <FormContent> labelFormContent = default; if (field.Key.Elements != null) { labelFormContent = ConvertTextReferences(field.Key.Elements, readResults); } LabelText = new FieldText(field.Key.Text, pageNumber, labelBoundingBox, labelFormContent); BoundingBox valueBoundingBox = field.Value.BoundingBox == null ? default : new BoundingBox(field.Value.BoundingBox); IReadOnlyList <FormContent> valueFormContent = default; if (field.Value.Elements != null) { valueFormContent = ConvertTextReferences(field.Value.Elements, readResults); } ValueText = new FieldText(field.Value.Text, pageNumber, valueBoundingBox, valueFormContent); Value = new FieldValue(new FieldValue_internal(field.Value.Text), readResults); }
internal static PageResult_internal DeserializePageResult_internal(JsonElement element) { int page = default; int?clusterId = default; IReadOnlyList <KeyValuePair_internal> keyValuePairs = default; IReadOnlyList <DataTable_internal> tables = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("page")) { page = property.Value.GetInt32(); continue; } if (property.NameEquals("clusterId")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } clusterId = property.Value.GetInt32(); continue; } if (property.NameEquals("keyValuePairs")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <KeyValuePair_internal> array = new List <KeyValuePair_internal>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(KeyValuePair_internal.DeserializeKeyValuePair_internal(item)); } keyValuePairs = array; continue; } if (property.NameEquals("tables")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <DataTable_internal> array = new List <DataTable_internal>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(DataTable_internal.DeserializeDataTable_internal(item)); } tables = array; continue; } } return(new PageResult_internal(page, clusterId, keyValuePairs, tables)); }
internal static PageResult_internal DeserializePageResult_internal(JsonElement element) { PageResult_internal result = new PageResult_internal(); foreach (var property in element.EnumerateObject()) { if (property.NameEquals("page")) { result.Page = property.Value.GetInt32(); continue; } if (property.NameEquals("clusterId")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.ClusterId = property.Value.GetInt32(); continue; } if (property.NameEquals("keyValuePairs")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.KeyValuePairs = new List <KeyValuePair_internal>(); foreach (var item in property.Value.EnumerateArray()) { result.KeyValuePairs.Add(KeyValuePair_internal.DeserializeKeyValuePair_internal(item)); } continue; } if (property.NameEquals("tables")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } result.Tables = new List <DataTable_internal>(); foreach (var item in property.Value.EnumerateArray()) { result.Tables.Add(DataTable_internal.DeserializeDataTable_internal(item)); } continue; } } return(result); }
internal ExtractedField(KeyValuePair_internal field, ReadResult_internal readResult) { // Unsupervised Confidence = field.Confidence; Label = field.Key.Text; LabelBoundingBox = field.Key.BoundingBox == null ? null : new BoundingBox(field.Key.BoundingBox); if (field.Key.Elements != null) { LabelRawExtractedItems = ConvertTextReferences(readResult, field.Key.Elements); } Value = field.Value.Text; ValueBoundingBox = new BoundingBox(field.Value.BoundingBox); if (field.Value.Elements != null) { ValueRawExtractedItems = ConvertTextReferences(readResult, field.Value.Elements); } }
#pragma warning disable CA1801 internal FormField(KeyValuePair_internal field, ReadResult_internal readResult) { #pragma warning restore CA1801 //Confidence = field.Confidence; //Name = field.Key.Text; //NameBoundingBox = new BoundingBox(field.Key.BoundingBox); //if (field.Key.Elements != null) //{ // NameTextElements = ConvertTextReferences(readResult, field.Key.Elements); //} //Value = field.Value.Text; //ValueBoundingBox = new BoundingBox(field.Value.BoundingBox); //if (field.Value.Elements != null) //{ // ValueTextElements = ConvertTextReferences(readResult, field.Value.Elements); //} }