NBoilerpipe.Document.TextBlock.AddLabels C# (CSharp) Method

AddLabels() public method

Adds a set of labels to this TextBlock . null-references are silently ignored.
public AddLabels ( ) : void
return void
        public virtual void AddLabels(params string[] l)
        {
            if (l == null)
            {
                return;
            }
            if (this.labels == null)
            {
                this.labels = new HashSet<string>();
            }
            foreach (string label in l)
            {
                this.labels.AddItem(label);
            }
        }

Same methods

TextBlock::AddLabels ( ICollection l ) : void

Usage Example

コード例 #1
0
 /// <exception cref="NBoilerpipe.BoilerpipeProcessingException"></exception>
 public bool Process(TextDocument doc)
 {
     bool changes = false;
     IList<TextBlock> blocks = doc.GetTextBlocks();
     IList<TextBlock> blocksNew = new AList<TextBlock>();
     foreach (TextBlock tb in blocks)
     {
         string text = tb.GetText();
         string[] paragraphs = text.Split("[\n\r]+");
         if (paragraphs.Length < 2)
         {
             blocksNew.AddItem(tb);
             continue;
         }
         bool isContent = tb.IsContent();
         ICollection<string> labels = tb.GetLabels();
         foreach (string p in paragraphs)
         {
             TextBlock tbP = new TextBlock(p);
             tbP.SetIsContent(isContent);
             tbP.AddLabels(labels);
             blocksNew.AddItem(tbP);
             changes = true;
         }
     }
     if (changes)
     {
         blocks.Clear();
         Sharpen.Collections.AddAll(blocks, blocksNew);
     }
     return changes;
 }
All Usage Examples Of NBoilerpipe.Document.TextBlock::AddLabels