class_docstr: 对 **CNN/Daily Mail** 数据进行适用于 ``extractive summarization task`` 的预处理，预处理之后的数据具备以下结构：
  
  .. csv-table::
     :header: "text", "summary", "label", "publication", "text_wd", "words", "seq_len", "target"
  
      "['I got new tires from them and... ','...']", "['The new tires...','...']", "[0, 1]", "cnndm", "[['I','got',...'.'],...,['...']]", "[[54,89,...,5],...,[9,43,..,0]]", "[1,1,...,0]", "[0,1,...,0]"
      "['Don't waste your time.  We had two...','...']", "['Time is precious','...']", "[1]", "cnndm", "[['Don't','waste',...,'.'],...,['...']]", "[[5234,653,...,5],...,[87,234,..,0]]", "[1,1,...,0]", "[1,1,...,0]"
      "['...']", "['...']", "[]", "cnndm", "[[''],...,['']]", "[[],...,[]]", "[]", "[]"
  
  :param vocab_size: 词表大小
  :param sent_max_len: 句子最大长度，不足的句子将 padding ，超出的将截断
  :param doc_max_timesteps: 文章最多句子个数，不足的将 padding，超出的将截断
  :param vocab_path: 外部词表路径
  :param domain: 是否需要建立 domain 词表
  :param num_proc: 处理数据时使用的进程数目。
class_docstr_tok: ["\u5bf9","*","*","CNN\/Daily","Mail","*","*","\u6570\u636e\u8fdb\u884c\u9002\u7528\u4e8e","``","extractive","summarization","task","``","\u7684\u9884\u5904\u7406\uff0c\u9884\u5904\u7406\u4e4b\u540e\u7684\u6570\u636e\u5177\u5907\u4ee5\u4e0b\u7ed3\u6784\uff1a","..","csv-table",":",":",":","header",":","``","text","''",",","``","summary","''",",","``","label","''",",","``","publication","''",",","``","text_wd","''",",","``","words","''",",","``","seq_len","''",",","``","target","''","``","[","'","I","got","new","tires","from","them","and","...","'",",","'","...","'","]","''",",","``","[","'The","new","tires","...","'",",","'","...","'","]","''",",","``","[","0",",","1","]","''",",","``","cnndm","''",",","``","[","[","'","I","'",",","'got","'",",","...","'.","'","]",",","...",",","[","'","...","'","]","]","''",",","``","[","[","54,89",",","...",",5","]",",","...",",","[","9,43",",","..",",0","]","]","''",",","``","[","1,1",",","...",",0","]","''",",","``","[","0,1",",","...",",0","]","''","``","[","'Do","n't","waste","your","time",".","We","had","two","...","'",",","'","...","'","]","''",",","``","[","'Time","is","precious","'",",","'","...","'","]","''",",","``","[","1","]","''",",","``","cnndm","''",",","``","[","[","'Do","n't","'",",","'waste","'",",","...",",","'.","'","]",",","...",",","[","'","...","'","]","]","''",",","``","[","[","5234,653",",","...",",5","]",",","...",",","[","87,234",",","..",",0","]","]","''",",","``","[","1,1",",","...",",0","]","''",",","``","[","1,1",",","...",",0","]","''","``","[","'","...","'","]","''",",","``","[","'","...","'","]","''",",","``","[","]","''",",","``","cnndm","''",",","``","[","[","``","]",",","...",",","[","``","]","]","''",",","``","[","[","]",",","...",",","[","]","]","''",",","``","[","]","''",",","``","[","]","''",":","param","vocab_size",":","\u8bcd\u8868\u5927\u5c0f",":","param","sent_max_len",":","\u53e5\u5b50\u6700\u5927\u957f\u5ea6\uff0c\u4e0d\u8db3\u7684\u53e5\u5b50\u5c06","padding","\uff0c\u8d85\u51fa\u7684\u5c06\u622a\u65ad",":","param","doc_max_timesteps",":","\u6587\u7ae0\u6700\u591a\u53e5\u5b50\u4e2a\u6570\uff0c\u4e0d\u8db3\u7684\u5c06","padding\uff0c\u8d85\u51fa\u7684\u5c06\u622a\u65ad",":","param","vocab_path",":","\u5916\u90e8\u8bcd\u8868\u8def\u5f84",":","param","domain",":","\u662f\u5426\u9700\u8981\u5efa\u7acb","domain","\u8bcd\u8868",":","param","num_proc",":","\u5904\u7406\u6570\u636e\u65f6\u4f7f\u7528\u7684\u8fdb\u7a0b\u6570\u76ee\u3002"]
docstr: ``data_bunlde`` 中的 :class:`~fastNLP.core.DataSet` 应该具备以下结构：
  
  .. csv-table::
     :header: "text", "summary", "label", "publication"
  
     "['I got new tires from them and... ','...']", "['The new tires...','...']", "[0, 1]", "cnndm"
     "['Don't waste your time.  We had two...','...']", "['Time is precious','...']", "[1]", "cnndm"
     "['...']", ['...']", "[]", "cnndm"
  
  :param data_bundle:
  :return: 处理后的 ``data_bundle``，新增以下列：
  
  .. csv-table::
     :header: "text_wd", "words", "seq_len", "target"
  
     "[['I','got',...'.'],...,['...']]", "[[54,89,...,5],...,[9,43,..,0]]", "[1,1,...,0]", "[0,1,...,0]"
     "[['Don't','waste',...,'.'],...,['...']]", "[[5234,653,...,5],...,[87,234,..,0]]", "[1,1,...,0]", "[1,1,...,0]"
     "[[''],...,['']]", "[[],...,[]]", "[]", "[]"
docstr_tok: ["``","data_bunlde","``","\u4e2d\u7684",":","class",":","`","~fastNLP.core.DataSet","`","\u5e94\u8be5\u5177\u5907\u4ee5\u4e0b\u7ed3\u6784\uff1a","..","csv-table",":",":",":","header",":","``","text","''",",","``","summary","''",",","``","label","''",",","``","publication","''","``","[","'","I","got","new","tires","from","them","and","...","'",",","'","...","'","]","''",",","``","[","'The","new","tires","...","'",",","'","...","'","]","''",",","``","[","0",",","1","]","''",",","``","cnndm","''","``","[","'Do","n't","waste","your","time",".","We","had","two","...","'",",","'","...","'","]","''",",","``","[","'Time","is","precious","'",",","'","...","'","]","''",",","``","[","1","]","''",",","``","cnndm","''","``","[","'","...","'","]","''",",","[","'","...","'","]","''",",","``","[","]","''",",","``","cnndm","''",":","param","data_bundle",":",":","return",":","\u5904\u7406\u540e\u7684","``","data_bundle","``","\uff0c\u65b0\u589e\u4ee5\u4e0b\u5217\uff1a","..","csv-table",":",":",":","header",":","``","text_wd","''",",","``","words","''",",","``","seq_len","''",",","``","target","''","``","[","[","'","I","'",",","'got","'",",","...","'.","'","]",",","...",",","[","'","...","'","]","]","''",",","``","[","[","54,89",",","...",",5","]",",","...",",","[","9,43",",","..",",0","]","]","''",",","``","[","1,1",",","...",",0","]","''",",","``","[","0,1",",","...",",0","]","''","``","[","[","'Do","n't","'",",","'waste","'",",","...",",","'.","'","]",",","...",",","[","'","...","'","]","]","''",",","``","[","[","5234,653",",","...",",5","]",",","...",",","[","87,234",",","..",",0","]","]","''",",","``","[","1,1",",","...",",0","]","''",",","``","[","1,1",",","...",",0","]","''","``","[","[","``","]",",","...",",","[","``","]","]","''",",","``","[","[","]",",","...",",","[","]","]","''",",","``","[","]","''",",","``","[","]","''"]
code: def process(self, data_bundle: DataBundle):
      r"""
      ``data_bunlde`` 中的 :class:`~fastNLP.core.DataSet` 应该具备以下结构：
  
      .. csv-table::
         :header: "text", "summary", "label", "publication"
  
         "['I got new tires from them and... ','...']", "['The new tires...','...']", "[0, 1]", "cnndm"
         "['Don't waste your time.  We had two...','...']", "['Time is precious','...']", "[1]", "cnndm"
         "['...']", ['...']", "[]", "cnndm"
  
      :param data_bundle:
      :return: 处理后的 ``data_bundle``，新增以下列：
  
      .. csv-table::
         :header: "text_wd", "words", "seq_len", "target"
  
         "[['I','got',...'.'],...,['...']]", "[[54,89,...,5],...,[9,43,..,0]]", "[1,1,...,0]", "[0,1,...,0]"
         "[['Don't','waste',...,'.'],...,['...']]", "[[5234,653,...,5],...,[87,234,..,0]]", "[1,1,...,0]", "[1,1,...,0]"
         "[[''],...,['']]", "[[],...,[]]", "[]", "[]"
      """
  
      if self.vocab_path is None:
          error_msg = "vocab file is not defined!"
          print(error_msg)
          raise RuntimeError(error_msg)
      data_bundle.apply_field(
          _lower_text,
          field_name="text",
          new_field_name="text",
          num_proc=self.num_proc,
      )
      data_bundle.apply_field(
          _lower_text,
          field_name="summary",
          new_field_name="summary",
          num_proc=self.num_proc,
      )
      data_bundle.apply_field(
          _split_list,
          field_name="text",
          new_field_name="text_wd",
          num_proc=self.num_proc,
      )
      # data_bundle.apply(lambda x: _lower_text(x['text']), new_field_name='text')
      # data_bundle.apply(lambda x: _lower_text(x['summary']), new_field_name='summary')
      # data_bundle.apply(lambda x: _split_list(x['text']), new_field_name='text_wd')
      data_bundle.apply(
          lambda x: _convert_label(x["label"], len(x["text"])),
          new_field_name="target",
      )
  
      data_bundle.apply_field(
          partial(_pad_sent, sent_max_len=self.sent_max_len),
          field_name="text_wd",
          new_field_name="words",
          num_proc=self.num_proc,
      )
      # data_bundle.apply(lambda x: _pad_sent(x["text_wd"], self.sent_max_len), new_field_name='words')
      # db.apply(lambda x: _token_mask(x["text_wd"], self.sent_max_len), new_field_name="pad_token_mask")
  
      # pad document
      data_bundle.apply_field(
          partial(
              _pad_doc,
              sent_max_len=self.sent_max_len,
              doc_max_timesteps=self.doc_max_timesteps,
          ),
          field_name="words",
          new_field_name="words",
          num_proc=self.num_proc,
      )
      data_bundle.apply_field(
          partial(_sent_mask, doc_max_timesteps=self.doc_max_timesteps),
          field_name="words",
          new_field_name="seq_len",
          num_proc=self.num_proc,
      )
      data_bundle.apply_field(
          partial(_pad_label, doc_max_timesteps=self.doc_max_timesteps),
          field_name="target",
          new_field_name="target",
          num_proc=self.num_proc,
      )
      # data_bundle.apply(lambda x: _pad_doc(x['words'], self.sent_max_len, self.doc_max_timesteps), new_field_name='words')
      # data_bundle.apply(lambda x: _sent_mask(x['words'], self.doc_max_timesteps), new_field_name='seq_len')
      # data_bundle.apply(lambda x: _pad_label(x['target'], self.doc_max_timesteps), new_field_name='target')
  
      data_bundle = _drop_empty_instance(data_bundle, "label")
  
      # print("[INFO] Load existing vocab from %s!" % self.vocab_path)
      word_list = []
      with open(self.vocab_path, "r", encoding="utf8") as vocab_f:
          cnt = 2  # pad and unk
          for line in vocab_f:
              pieces = line.split("\t")
              word_list.append(pieces[0])
              cnt += 1
              if cnt > self.vocab_size:
                  break
      vocabs = Vocabulary(
          max_size=self.vocab_size, padding=WORD_PAD, unknown=WORD_UNK
      )
      vocabs.add_word_lst(word_list)
      vocabs.build_vocab()
      data_bundle.set_vocab(vocabs, "vocab")
  
      if self.domain is True:
          domaindict = Vocabulary(padding=None, unknown=DOMAIN_UNK)
          domaindict.from_dataset(
              data_bundle.get_dataset("train"), field_name="publication"
          )
          data_bundle.set_vocab(domaindict, "domain")
  
      return data_bundle
  
imports: import os
  import numpy
  from functools import partial
  from .pipe import Pipe
  from .utils import _drop_empty_instance
  from ..loader.summarization import ExtCNNDMLoader
  from ..data_bundle import DataBundle
  from ...core.vocabulary import Vocabulary
label_desc: Use image node_id 2 for calling the ExtCNNDMPipe obj's underlying member method code with example usage: obj.process(data_bundle) and returns: data_bundle