コード例 #1
0
        protected void AddTextBlock(TextBlock tb)
        {
            foreach (var l in FontSizeStack)
            {
                if (l != null)
                {
                    tb.AddLabel("font-" + l);
                    break;
                }
            }
            foreach (var labelStack in _labelStacks)
            {
                if (labelStack != null)
                {
                    foreach (LabelAction labels in labelStack)
                    {
                        if (labels != null)
                        {
                            labels.AddTo(tb);
                        }
                    }
                }
            }

            _textBlocks.Add(tb);
        }
コード例 #2
0
        public bool Process(TextDocument doc)
        {
            List <TextBlock> textBlocks = doc.TextBlocks;

            if (textBlocks.Count < 2)
            {
                return(false);
            }

            bool      changes    = false;
            TextBlock blockBelow = null;

            textBlocks.Reverse();
            foreach (TextBlock block in textBlocks)
            {
                if (blockBelow == null)
                {
                    blockBelow = block;
                    continue;
                }

                IEnumerable <string> labels = block.Labels;
                if (labels != null)
                {
                    IList <string> enumerable = labels.ToList();
                    if (enumerable.Count > 0)
                    {
                        foreach (string l in enumerable)
                        {
                            blockBelow.AddLabel(_labelPrefix + l);
                        }
                        changes = true;
                    }
                }
                blockBelow = block;
            }

            return(changes);
        }
コード例 #3
0
        /// <exception cref="NBoilerpipe.BoilerpipeProcessingException"></exception>
        public bool Process(TextDocument doc)
        {
            IList <TextBlock> textBlocks = doc.GetTextBlocks();

            if (textBlocks.Count < 2)
            {
                return(false);
            }
            bool      changes    = false;
            int       remaining  = textBlocks.Count;
            TextBlock blockBelow = null;
            TextBlock block;

            for (ListIterator <TextBlock> it = textBlocks.ListIterator <TextBlock>(textBlocks.Count); it.HasPrevious
                     ();)
            {
                if (--remaining <= 0)
                {
                    break;
                }
                if (blockBelow == null)
                {
                    blockBelow = it.Previous();
                    continue;
                }
                block = it.Previous();
                ICollection <string> labels = block.GetLabels();
                if (labels != null && !labels.IsEmpty())
                {
                    foreach (string l in labels)
                    {
                        blockBelow.AddLabel(labelPrefix + l);
                    }
                    changes = true;
                }
                blockBelow = block;
            }
            return(changes);
        }