This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add annotation & small changes
- Loading branch information
Showing
6 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
|
||
import jsonlines | ||
|
||
curr_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
url_to_dataset = { | ||
"QuALITY.v1.0.1.train": "https://raw.githubusercontent.com/nyu-mll/quality/main/data/v1.0.1/QuALITY.v1.0.1.train", | ||
"QuALITY.v1.0.1.dev": "https://raw.githubusercontent.com/nyu-mll/quality/main/data/v1.0.1/QuALITY.v1.0.1.dev", | ||
"QuALITY.v1.0.1.test": "https://raw.githubusercontent.com/nyu-mll/quality/main/data/v1.0.1/QuALITY.v1.0.1.test", | ||
} | ||
|
||
|
||
def download_dataset(name): | ||
if name not in url_to_dataset: | ||
raise ValueError(f"Unknown dataset {name}") | ||
url = url_to_dataset[name] | ||
dataset_path = os.path.join(curr_dir, name) | ||
print(f"Downloading dataset {name} from {url} to {dataset_path}") | ||
os.system(f"curl {url} -o {dataset_path}") | ||
|
||
|
||
def iter_dataset(name): | ||
dataset_path = os.path.join(curr_dir, name) | ||
if not os.path.exists(dataset_path): | ||
download_dataset(name) | ||
with jsonlines.open(dataset_path) as reader: | ||
for obj in reader: | ||
yield obj | ||
|
||
|
||
def extract_dataset(name, number): | ||
i = 0 | ||
for obj in iter_dataset(name): | ||
if i == number: | ||
return obj | ||
i += 1 | ||
|
||
|
||
if __name__ == "__main__": | ||
data = extract_dataset("QuALITY.v1.0.1.dev", 2) | ||
print(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters