rename download_and_unzip to make it more specific

This commit is contained in:
rasbt 2024-05-12 08:36:24 -05:00
parent 49306b271f
commit beeaf323f1
4 changed files with 9 additions and 9 deletions

View File

@ -170,7 +170,7 @@
"from pathlib import Path\n", "from pathlib import Path\n",
"import pandas as pd\n", "import pandas as pd\n",
"from previous_chapters import (\n", "from previous_chapters import (\n",
" download_and_unzip,\n", " download_and_unzip_spam_data,\n",
" create_balanced_dataset,\n", " create_balanced_dataset,\n",
" random_split\n", " random_split\n",
")\n", ")\n",
@ -181,7 +181,7 @@
"extracted_path = \"sms_spam_collection\"\n", "extracted_path = \"sms_spam_collection\"\n",
"data_file_path = Path(extracted_path) / \"SMSSpamCollection.tsv\"\n", "data_file_path = Path(extracted_path) / \"SMSSpamCollection.tsv\"\n",
"\n", "\n",
"download_and_unzip(url, zip_path, extracted_path, data_file_path)\n", "download_and_unzip_spam_data(url, zip_path, extracted_path, data_file_path)\n",
"\n", "\n",
"df = pd.read_csv(data_file_path, sep=\"\\t\", header=None, names=[\"Label\", \"Text\"])\n", "df = pd.read_csv(data_file_path, sep=\"\\t\", header=None, names=[\"Label\", \"Text\"])\n",
"balanced_df = create_balanced_dataset(df)\n", "balanced_df = create_balanced_dataset(df)\n",
@ -1415,7 +1415,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.4" "version": "3.10.6"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -362,7 +362,7 @@ def evaluate_model(model, train_loader, val_loader, device, eval_iter):
##################################### #####################################
def download_and_unzip(url, zip_path, extracted_path, data_file_path): def download_and_unzip_spam_data(url, zip_path, extracted_path, data_file_path):
if data_file_path.exists(): if data_file_path.exists():
print(f"{data_file_path} already exists. Skipping download and extraction.") print(f"{data_file_path} already exists. Skipping download and extraction.")
return return

View File

@ -187,7 +187,7 @@
"extracted_path = \"sms_spam_collection\"\n", "extracted_path = \"sms_spam_collection\"\n",
"data_file_path = Path(extracted_path) / \"SMSSpamCollection.tsv\"\n", "data_file_path = Path(extracted_path) / \"SMSSpamCollection.tsv\"\n",
"\n", "\n",
"def download_and_unzip(url, zip_path, extracted_path, data_file_path):\n", "def download_and_unzip_spam_data(url, zip_path, extracted_path, data_file_path):\n",
" if data_file_path.exists():\n", " if data_file_path.exists():\n",
" print(f\"{data_file_path} already exists. Skipping download and extraction.\")\n", " print(f\"{data_file_path} already exists. Skipping download and extraction.\")\n",
" return\n", " return\n",
@ -206,7 +206,7 @@
" os.rename(original_file_path, data_file_path)\n", " os.rename(original_file_path, data_file_path)\n",
" print(f\"File downloaded and saved as {data_file_path}\")\n", " print(f\"File downloaded and saved as {data_file_path}\")\n",
"\n", "\n",
"download_and_unzip(url, zip_path, extracted_path, data_file_path)" "download_and_unzip_spam_data(url, zip_path, extracted_path, data_file_path)"
] ]
}, },
{ {
@ -2347,7 +2347,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.11.4" "version": "3.10.6"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -46,7 +46,7 @@
" print(f\"File download and saved as {new_file_path}\")\n", " print(f\"File download and saved as {new_file_path}\")\n",
"\n", "\n",
"# Execute the function\n", "# Execute the function\n",
"download_and_unzip(url, zip_path, extract_to, new_file_path)" "download_and_unzip_spam_data(url, zip_path, extract_to, new_file_path)"
] ]
}, },
{ {
@ -510,7 +510,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.12" "version": "3.10.6"
} }
}, },
"nbformat": 4, "nbformat": 4,