给 _get_dataset_url 增加了使用自定义数据集下载路径的能力

This commit is contained in:
willqvq 2020-12-16 10:40:00 +08:00
parent bffde7857a
commit 84776696cd

View File

@ -312,7 +312,8 @@ def _read_extend_url_file(filename, name)->str:
return parts[1]
return None
def _get_dataset_url(name):
def _get_dataset_url(name, dataset_dir: dict = None):
r"""
给定dataset的名称返回下载url
@ -323,8 +324,9 @@ def _get_dataset_url(name):
url = _read_extend_url_file(FASTNLP_EXTEND_DATASET_URL, name)
if url:
return url
filename = DATASET_DIR.get(name, None)
dataset_dir = DATASET_DIR if dataset_dir is None else dataset_dir
filename = dataset_dir.get(name, None)
if filename:
url = _get_base_url('dataset') + filename
return url