Datasets:
Guillaume Raille
commited on
add code to download the pdfs
Browse files
main.py
CHANGED
|
@@ -20,7 +20,18 @@ def download_pdf(url: str, output_path: str) -> None:
|
|
| 20 |
|
| 21 |
|
| 22 |
def main():
|
| 23 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
# fetch from
|
| 26 |
# 2. process data into clean tiny-shakespeare like format
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
def main():
|
| 23 |
+
# make sure data directory exists
|
| 24 |
+
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
| 25 |
+
|
| 26 |
+
# download raw PDFs if they don't already exist
|
| 27 |
+
for url in RAW_PDF_URLS:
|
| 28 |
+
filename = url.split("/")[-1]
|
| 29 |
+
output_path = DATA_DIR / filename
|
| 30 |
+
if not output_path.exists():
|
| 31 |
+
print(f"Downloading {filename}...")
|
| 32 |
+
download_pdf(url, output_path)
|
| 33 |
+
else:
|
| 34 |
+
print(f"{filename} already exists, skipping download.")
|
| 35 |
|
| 36 |
# fetch from
|
| 37 |
# 2. process data into clean tiny-shakespeare like format
|