torchnlp.download package

The torchnlp.download package contains modules useful for download and extracting datasets.

torchnlp.download.download_file_maybe_extract(url, directory, filename=None, extension=None, check_files=[])[source]

Download the file at url to directory. Extract to directory if tar or zip.

Parameters:
  • url (str or Path) – Url of file.
  • directory (str) – Directory to download to.
  • filename (str, optional) – Name of the file to download; Otherwise, a filename is extracted from the url.
  • extension (str, optional) – Extension of the file; Otherwise, attempts to extract extension from the filename.
  • check_files (list of str or Path) – Check if these files exist, ensuring the download succeeded. If these files exist before the download, the download is skipped.
Returns:

Filename of download file.

Return type:

(str)

Raises:

ValueError – Error if one of the check_files are not found following the download.

torchnlp.download.download_files_maybe_extract(urls, directory, check_files=[])[source]

Download the files at urls to directory. Extract to directory if tar or zip.

Parameters:
  • urls (str) – Url of files.
  • directory (str) – Directory to download to.
  • check_files (list of str) – Check if these files exist, ensuring the download succeeded. If these files exist before the download, the download is skipped.
Raises:

ValueError – Error if one of the check_files are not found following the download.