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
todirectory
. Extract todirectory
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 thecheck_files
are not found following the download.
-
torchnlp.download.
download_files_maybe_extract
(urls, directory, check_files=[])[source]¶ Download the files at
urls
todirectory
. Extract todirectory
if tar or zip.Parameters: Raises: ValueError
– Error if one of thecheck_files
are not found following the download.