Пример #1
0
        public FieldValue(Block block, List <string> children, Dictionary <string, Block> blocks)
        {
            this.Block      = block;
            this.Confidence = block.Confidence;
            this.Geometry   = block.Geometry;
            this.Id         = block.Id;
            this.Text       = string.Empty;
            this.Content    = new List <dynamic>();

            var words = new List <string>();

            if (children != null && children.Count > 0)
            {
                children.ForEach(c => {
                    var wordBlock = blocks[c];
                    if (wordBlock.BlockType == "WORD")
                    {
                        var w = new Word(wordBlock, blocks);
                        this.Content.Add(w);
                        words.Add(w.Text);
                    }
                    else if (wordBlock.BlockType == "SELECTION_ELEMENT")
                    {
                        var selection = new SelectionElement(wordBlock, blocks);
                        this.Content.Add(selection);
                        words.Add(selection.SelectionStatus);
                    }
                });
            }

            if (words.Count > 0)
            {
                this.Text = string.Join(" ", words);
            }
        }
Пример #2
0
        public Cell(Block block, Dictionary <string, Block> blocks)
        {
            if (block == null)
            {
                return;
            }
            this.Block       = block;
            this.ColumnIndex = block.ColumnIndex;
            this.ColumnSpan  = block.ColumnSpan;
            this.Confidence  = block.Confidence;
            this.Content     = new List <dynamic>();
            this.Geometry    = block.Geometry;
            this.Id          = block.Id;
            this.RowIndex    = block.RowIndex;
            this.RowSpan     = block.RowSpan;
            this.Text        = string.Empty;

            var relationships = block.Relationships;

            if (relationships != null && relationships.Count > 0)
            {
                relationships.ForEach(r => {
                    if (r.Type == "CHILD")
                    {
                        r.Ids.ForEach(id => {
                            var rb = blocks[id];
                            if (rb != null && rb.BlockType == "WORD")
                            {
                                var w = new Word(rb, blocks);
                                this.Content.Add(w);
                                this.Text = this.Text + w.Text + " ";
                            }
                            else if (rb != null && rb.BlockType == "SELECTION_ELEMENT")
                            {
                                var se = new SelectionElement(rb, blocks);
                                this.Content.Add(se);
                                this.Text = this.Text + se.SelectionStatus + ", ";
                            }
                        });
                    }
                });
            }
        }