Ejemplo n.º 1
0
 internal TextLine(string text, IReadOnlyList <float> boundingBox, IReadOnlyList <TextWord> words, TextAppearance appearance)
 {
     Text        = text;
     BoundingBox = boundingBox;
     Words       = words;
     Appearance  = appearance;
 }
Ejemplo n.º 2
0
 internal TextLine(string text, IReadOnlyList <float> boundingBox, FormRecognizerLanguage?language, IReadOnlyList <TextWord> words, TextAppearance appearance)
 {
     Text        = text;
     BoundingBox = boundingBox;
     Language    = language;
     Words       = words;
     Appearance  = appearance;
 }
Ejemplo n.º 3
0
        internal static TextLine DeserializeTextLine(JsonElement element)
        {
            string text = default;
            IReadOnlyList <float>             boundingBox = default;
            Optional <FormRecognizerLanguage> language    = default;
            IReadOnlyList <TextWord>          words       = default;
            Optional <TextAppearance>         appearance  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("text"))
                {
                    text = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("boundingBox"))
                {
                    List <float> array = new List <float>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetSingle());
                    }
                    boundingBox = array;
                    continue;
                }
                if (property.NameEquals("language"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    language = new FormRecognizerLanguage(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("words"))
                {
                    List <TextWord> array = new List <TextWord>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextWord.DeserializeTextWord(item));
                    }
                    words = array;
                    continue;
                }
                if (property.NameEquals("appearance"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    appearance = TextAppearance.DeserializeTextAppearance(property.Value);
                    continue;
                }
            }
            return(new TextLine(text, boundingBox, Optional.ToNullable(language), words, appearance.Value));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FormRecognizer.Models.FormLine"/> class.
        /// </summary>
        /// <param name="boundingBox">The quadrilateral bounding box that outlines the text of this element.</param>
        /// <param name="pageNumber">The 1-based number of the page in which this element is present.</param>
        /// <param name="text">The text of this form element.</param>
        /// <param name="words">A list of the words that make up the line.</param>
        /// <param name="appearance">An object representing the appearance of the text line.</param>
        /// <returns>A new <see cref="FormRecognizer.Models.FormLine"/> instance for mocking.</returns>
        public static FormLine FormLine(FieldBoundingBox boundingBox, int pageNumber, string text, IReadOnlyList <FormWord> words, TextAppearance appearance)
        {
            words = words?.ToList();

            return(new FormLine(boundingBox, pageNumber, text, words, appearance));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FormLine"/> class.
 /// </summary>
 /// <param name="boundingBox">The quadrilateral bounding box that outlines the text of this element.</param>
 /// <param name="pageNumber">The 1-based number of the page in which this element is present.</param>
 /// <param name="text">The text of this form element.</param>
 /// <param name="words">A list of the words that make up the line.</param>
 /// <param name="appearance">An object representing the appearance of the text line.</param>
 internal FormLine(FieldBoundingBox boundingBox, int pageNumber, string text, IReadOnlyList <FormWord> words, TextAppearance appearance)
     : base(boundingBox, pageNumber, text)
 {
     Words      = words;
     Appearance = appearance;
 }