internal RawExtractedLine(TextLine_internal textLine)
 {
     Text        = textLine.Text;
     BoundingBox = new BoundingBox(textLine.BoundingBox);
     Language    = textLine.Language.ToString();
     Words       = ConvertWords(textLine.Words);
 }
        internal static ReadResult_internal DeserializeReadResult_internal(JsonElement element)
        {
            ReadResult_internal result = new ReadResult_internal();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("page"))
                {
                    result.Page = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("angle"))
                {
                    result.Angle = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("width"))
                {
                    result.Width = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("height"))
                {
                    result.Height = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    result.Unit = property.Value.GetString().ToLengthUnit();
                    continue;
                }
                if (property.NameEquals("language"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Language = new Language_internal(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("lines"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Lines = new List <TextLine_internal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Lines.Add(TextLine_internal.DeserializeTextLine_internal(item));
                    }
                    continue;
                }
            }
            return(result);
        }
        internal static TextLine_internal DeserializeTextLine_internal(JsonElement element)
        {
            TextLine_internal result = new TextLine_internal();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("text"))
                {
                    result.Text = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("boundingBox"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.BoundingBox.Add(item.GetSingle());
                    }
                    continue;
                }
                if (property.NameEquals("language"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    result.Language = new Language_internal(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("words"))
                {
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        result.Words.Add(TextWord_internal.DeserializeTextWord_internal(item));
                    }
                    continue;
                }
            }
            return(result);
        }
Example #4
0
 internal FormLine(TextLine_internal textLine, int pageNumber)
     : base(new BoundingBox(textLine.BoundingBox), pageNumber, textLine.Text)
 {
     Words = ConvertWords(textLine.Words, pageNumber);
 }
Example #5
0
        internal static ReadResult_internal DeserializeReadResult_internal(JsonElement element)
        {
            int               page     = default;
            float             angle    = default;
            float             width    = default;
            float             height   = default;
            LengthUnit        unit     = default;
            Language_internal?language = default;
            IReadOnlyList <TextLine_internal> lines = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("page"))
                {
                    page = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("angle"))
                {
                    angle = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("width"))
                {
                    width = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("height"))
                {
                    height = property.Value.GetSingle();
                    continue;
                }
                if (property.NameEquals("unit"))
                {
                    unit = property.Value.GetString().ToLengthUnit();
                    continue;
                }
                if (property.NameEquals("language"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    language = new Language_internal(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("lines"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <TextLine_internal> array = new List <TextLine_internal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(TextLine_internal.DeserializeTextLine_internal(item));
                        }
                    }
                    lines = array;
                    continue;
                }
            }
            return(new ReadResult_internal(page, angle, width, height, unit, language, lines));
        }