Skip to content

Commit

Permalink
change download method to gdown (now it works)
Browse files Browse the repository at this point in the history
  • Loading branch information
sabilmakbar committed May 20, 2024
1 parent 9a07e06 commit 8c5c63d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions seacrowd/sea_datasets/m3ls/m3ls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
SEA Crowd Data Loader for M3LS.
SEA Crowd Data Loader for Bloom Speech.
"""
import json
import os
Expand Down Expand Up @@ -51,7 +51,7 @@
_HOMEPAGE = "https://github.com/anubhav-jangra/M3LS/tree/main"
_LICENSE = Licenses.MIT.value

_URL = "https://www.googleapis.com/drive/v3/files/1Kznkw7YpRiWpdgH4_SVNwp0uGf3j-5e2?alt=media&key=AIzaSyDVCNpmfKmJ0gPeyZ8YWMca9ZOKz0CWdgs"
_URL = "https://drive.google.com/uc?id=1Kznkw7YpRiWpdgH4_SVNwp0uGf3j-5e2"

_SUPPORTED_TASKS = [Tasks.SUMMARIZATION, Tasks.IMAGE_CAPTIONING]
_SOURCE_VERSION = "1.0.0"
Expand Down Expand Up @@ -120,8 +120,22 @@ def _info(self) -> datasets.DatasetInfo:
)

def _split_generators(self, dl_manager: DownloadManager) -> List[datasets.SplitGenerator]:
local_path = dl_manager.download_and_extract(_URL)
local_path = os.path.join(local_path.title(), "bbcindonesia")
try:
import gdown
except ImportError:
raise ImportError("Please install `gdown` to enable downloading data from google drive.")

# Download from Google drive
output_dir = os.path.join(os.getcwd(), "data", "m3ls")
if not os.path.exists(output_dir):
os.mkdir(output_dir)
output_file = output_dir + "/m3ls.zip"
if not os.path.exists(output_file):
gdown.download(_URL, str(output_file), fuzzy=True)
else:
logger.info(f"File already downloaded: {str(output_file)}")

local_path = os.path.join(dl_manager.extract(output_file).title(), "bbcindonesia")

# there are two folders all containing json files, namely "processed" and "articles"
# both are having articles info with url, text, and accompanied resource scrapped (i.e image & captions, related articles)
Expand Down

0 comments on commit 8c5c63d

Please sign in to comment.