| | | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | | 2 | | // Licensed under the MIT License. |
| | | 3 | | |
| | | 4 | | using System.Collections.Generic; |
| | | 5 | | |
| | | 6 | | namespace Azure.AI.FormRecognizer.Models |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents a line of text recognized from the input document. |
| | | 10 | | /// </summary> |
| | | 11 | | public class FormLine : FormElement |
| | | 12 | | { |
| | | 13 | | internal FormLine(TextLine textLine, int pageNumber) |
| | 4936 | 14 | | : base(new BoundingBox(textLine.BoundingBox), pageNumber, textLine.Text) |
| | | 15 | | { |
| | 4936 | 16 | | Words = ConvertWords(textLine.Words, pageNumber); |
| | 4936 | 17 | | } |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// A list of the words that make up the line. |
| | | 21 | | /// </summary> |
| | 14004 | 22 | | public IReadOnlyList<FormWord> Words { get; } |
| | | 23 | | |
| | | 24 | | private static IReadOnlyList<FormWord> ConvertWords(IReadOnlyList<TextWord> textWords, int pageNumber) |
| | | 25 | | { |
| | 4936 | 26 | | List<FormWord> rawWords = new List<FormWord>(); |
| | | 27 | | |
| | 31072 | 28 | | foreach (TextWord textWord in textWords) |
| | | 29 | | { |
| | 10600 | 30 | | rawWords.Add(new FormWord(textWord, pageNumber)); |
| | | 31 | | } |
| | | 32 | | |
| | 4936 | 33 | | return rawWords; |
| | | 34 | | } |
| | | 35 | | } |
| | | 36 | | } |