class_docstr: 读取 **MSRA-NER** 数据，如果您要使用该数据，请引用以下的文章：
  
  Gina-Anne Levow, 2006, The Third International Chinese Language Processing Bakeoff: Word Segmentation and Named Entity Recognition.
      
  数据中的格式应该类似于下列的内容::
  
      把       O
      欧       B-LOC
  
      美       B-LOC
      、       O
  
      港       B-LOC
      台       B-LOC
  
      流       O
      行       O
  
      的       O
  
      食       O
  
      ...
  
  读取的 :class:`~fastNLP.core.DataSet` 将具备以下的数据结构：
  
  .. csv-table::
      :header: "raw_chars", "target"
  
      "['把', '欧'] ", "['O', 'B-LOC']"
      "['美', '、']", "['B-LOC', 'O']"
      "[...]", "[...]"
class_docstr_tok: ["\u8bfb\u53d6","*","*","MSRA-NER","*","*","\u6570\u636e\uff0c\u5982\u679c\u60a8\u8981\u4f7f\u7528\u8be5\u6570\u636e\uff0c\u8bf7\u5f15\u7528\u4ee5\u4e0b\u7684\u6587\u7ae0\uff1a","Gina-Anne","Levow",",","2006",",","The","Third","International","Chinese","Language","Processing","Bakeoff",":","Word","Segmentation","and","Named","Entity","Recognition",".","\u6570\u636e\u4e2d\u7684\u683c\u5f0f\u5e94\u8be5\u7c7b\u4f3c\u4e8e\u4e0b\u5217\u7684\u5185\u5bb9",":",":","\u628a","O","\u6b27","B-LOC","\u7f8e","B-LOC","\u3001","O","\u6e2f","B-LOC","\u53f0","B-LOC","\u6d41","O","\u884c","O","\u7684","O","\u98df","O","...","\u8bfb\u53d6\u7684",":","class",":","`","~fastNLP.core.DataSet","`","\u5c06\u5177\u5907\u4ee5\u4e0b\u7684\u6570\u636e\u7ed3\u6784\uff1a","..","csv-table",":",":",":","header",":","``","raw_chars","''",",","``","target","''","``","[","'","\u628a","'",",","'","\u6b27","'","]","``",",","``","[","'","O","'",",","'","B-LOC","'","]","''","``","[","'","\u7f8e","'",",","'\u3001","'","]","''",",","``","[","'","B-LOC","'",",","'","O","'","]","''","``","[","...","]","''",",","``","[","...","]","''"]
docstr: 自动下载 **MSAR-NER** 的数据。
  
  下载完成后在 ``output_dir`` 中有 ``train.conll`` , ``test.conll`` , ``dev.conll`` 三个文件。
  如果 ``dev_ratio`` 为 0，则只有 ``train.conll`` 和 ``test.conll`` 。
  
  :param dev_ratio: 如果路径中没有验证集 ，从 train 划分多少作为 dev 的数据。如果为 **0** ，则不划分 dev
  :param re_download: 是否重新下载数据，以重新切分数据。
  :return: 数据集的目录地址
  :return:
docstr_tok: ["\u81ea\u52a8\u4e0b\u8f7d","*","*","MSAR-NER","*","*","\u7684\u6570\u636e\u3002","\u4e0b\u8f7d\u5b8c\u6210\u540e\u5728","``","output_dir","``","\u4e2d\u6709","``","train.conll","``",",","``","test.conll","``",",","``","dev.conll","``","\u4e09\u4e2a\u6587\u4ef6\u3002","\u5982\u679c","``","dev_ratio","``","\u4e3a","0\uff0c\u5219\u53ea\u6709","``","train.conll","``","\u548c","``","test.conll","``","\u3002",":","param","dev_ratio",":","\u5982\u679c\u8def\u5f84\u4e2d\u6ca1\u6709\u9a8c\u8bc1\u96c6","\uff0c\u4ece","train","\u5212\u5206\u591a\u5c11\u4f5c\u4e3a","dev","\u7684\u6570\u636e\u3002\u5982\u679c\u4e3a","*","*","0","*","*","\uff0c\u5219\u4e0d\u5212\u5206","dev",":","param","re_download",":","\u662f\u5426\u91cd\u65b0\u4e0b\u8f7d\u6570\u636e\uff0c\u4ee5\u91cd\u65b0\u5207\u5206\u6570\u636e\u3002",":","return",":","\u6570\u636e\u96c6\u7684\u76ee\u5f55\u5730\u5740",":","return",":"]
code: def download(
      self, dev_ratio: float = 0.1, re_download: bool = False
  ) -> str:
      r"""
      自动下载 **MSAR-NER** 的数据。
  
      下载完成后在 ``output_dir`` 中有 ``train.conll`` , ``test.conll`` , ``dev.conll`` 三个文件。
      如果 ``dev_ratio`` 为 0，则只有 ``train.conll`` 和 ``test.conll`` 。
  
      :param dev_ratio: 如果路径中没有验证集 ，从 train 划分多少作为 dev 的数据。如果为 **0** ，则不划分 dev
      :param re_download: 是否重新下载数据，以重新切分数据。
      :return: 数据集的目录地址
      :return:
      """
      dataset_name = "msra-ner"
      data_dir = self._get_dataset_path(dataset_name=dataset_name)
      modify_time = 0
      for filepath in glob.glob(os.path.join(data_dir, "*")):
          modify_time = os.stat(filepath).st_mtime
          break
      if (
          time.time() - modify_time > 1 and re_download
      ):  # 通过这种比较丑陋的方式判断一下文件是否是才下载的
          shutil.rmtree(data_dir)
          data_dir = self._get_dataset_path(dataset_name=dataset_name)
  
      if not os.path.exists(os.path.join(data_dir, "dev.conll")):
          if dev_ratio > 0:
              assert (
                  0 < dev_ratio < 1
              ), "dev_ratio should be in range (0,1)."
              try:
                  with open(
                      os.path.join(data_dir, "train.conll"),
                      "r",
                      encoding="utf-8",
                  ) as f, open(
                      os.path.join(data_dir, "middle_file.conll"),
                      "w",
                      encoding="utf-8",
                  ) as f1, open(
                      os.path.join(data_dir, "dev.conll"),
                      "w",
                      encoding="utf-8",
                  ) as f2:
                      lines = []  # 一个sample包含很多行
                      for line in f:
                          line = line.strip()
                          if line:
                              lines.append(line)
                          else:
                              if random.random() < dev_ratio:
                                  f2.write("\n".join(lines) + "\n\n")
                              else:
                                  f1.write("\n".join(lines) + "\n\n")
                              lines.clear()
                  os.remove(os.path.join(data_dir, "train.conll"))
                  os.renames(
                      os.path.join(data_dir, "middle_file.conll"),
                      os.path.join(data_dir, "train.conll"),
                  )
              finally:
                  if os.path.exists(
                      os.path.join(data_dir, "middle_file.conll")
                  ):
                      os.remove(
                          os.path.join(data_dir, "middle_file.conll")
                      )
  
      return data_dir
  
imports: import glob
  import os
  import random
  import shutil
  import time
  from typing import List
  from .loader import Loader
  from ..file_reader import _read_conll
  from fastNLP.core.dataset import DataSet, Instance
label_desc: Use image node_id 2 for calling the MsraNERLoader obj's underlying member method code with example usage: obj.download(dev_ratio, re_download) and returns: data_dir