Exemple #1
0
        public Cell(Block block, List <Block> blocks)
        {
            Block       = block;
            ColumnIndex = block.ColumnIndex;
            ColumnSpan  = block.ColumnSpan;
            Confidence  = block.Confidence;
            Content     = new List <dynamic>();
            Geometry    = block.Geometry;
            Id          = block.Id;
            RowIndex    = block.RowIndex;
            RowSpan     = block.RowSpan;
            Text        = string.Empty;

            var relationships = block.Relationships;

            if (relationships != null && relationships.Count > 0)
            {
                foreach (var relationship in relationships)
                {
                    if (relationship.Type == RelationshipType.CHILD)
                    {
                        foreach (var id in relationship.Ids)
                        {
                            var matchedBlock = blocks.Find(b => b.Id == id);

                            if (matchedBlock?.BlockType == BlockType.WORD)
                            {
                                var word = new Word(matchedBlock);
                                Content.Add(word);
                                Text = Text + word.Text + " ";
                            }
                            else if (matchedBlock?.BlockType == BlockType.SELECTION_ELEMENT)
                            {
                                var selectionElement = new SelectionElement(matchedBlock);
                                Content.Add(selectionElement);
                                Text = Text + selectionElement.SelectionStatus + ", ";
                            }
                        }
                    }
                }
            }
        }
        public FieldValue(Block block, List <string> ids, List <Block> blocks)
        {
            Block      = block;
            Confidence = block.Confidence;
            Geometry   = block.Geometry;
            Id         = block.Id;
            Text       = string.Empty;
            Content    = new List <dynamic>();

            var words = new List <string>();

            if (ids != null && ids.Count > 0)
            {
                foreach (var id in ids)
                {
                    var wordBlock = blocks.Find(b => b.Id == id);
                    if (wordBlock?.BlockType == BlockType.WORD)
                    {
                        var word = new Word(wordBlock);
                        Content.Add(word);
                        words.Add(word.Text);
                    }
                    else if (wordBlock?.BlockType == BlockType.SELECTION_ELEMENT)
                    {
                        var selection = new SelectionElement(wordBlock);
                        Content.Add(selection);
                        words.Add(selection.SelectionStatus);
                    }
                }
            }

            if (words.Count > 0)
            {
                Text = string.Join(" ", words);
            }
        }