Upload load_script.py
Browse files- load_script.py +95 -0
load_script.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
import json
|
| 3 |
+
import os
|
| 4 |
+
import datasets
|
| 5 |
+
|
| 6 |
+
_DESCRIPTION = """ Depression Severity Dataset. Unknown License.
|
| 7 |
+
"""
|
| 8 |
+
_CITATION = """
|
| 9 |
+
@inproceedings{naseem2022early,
|
| 10 |
+
title={Early Identification of Depression Severity Levels on Reddit Using Ordinal Classification},
|
| 11 |
+
author={Naseem, Usman and Dunn, Adam G and Kim, Jinman and Khushi, Matloob},
|
| 12 |
+
booktitle={Proceedings of the ACM Web Conference 2022},
|
| 13 |
+
pages={2563--2572},
|
| 14 |
+
year={2022}
|
| 15 |
+
}
|
| 16 |
+
"""
|
| 17 |
+
_URLs = {
|
| 18 |
+
"whole": "https://huggingface.co/datasets/siyangliu/Depression_Severity_Dataset/blob/main/Reddit_depression_dataset.json",
|
| 19 |
+
"train": "https://huggingface.co/datasets/siyangliu/Depression_Severity_Dataset/blob/main/Reddit_depression_dataset_train.json",
|
| 20 |
+
"val": "https://huggingface.co/datasets/siyangliu/Depression_Severity_Dataset/blob/main/Reddit_depression_dataset_val.json",
|
| 21 |
+
"test": "https://huggingface.co/datasets/siyangliu/Depression_Severity_Dataset/blob/main/Reddit_depression_dataset_test.json",
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
class Reddit_depression(datasets.GeneratorBasedBuilder):
|
| 25 |
+
"""Reddit_depression dataset."""
|
| 26 |
+
|
| 27 |
+
VERSION = datasets.Version("1.1.0")
|
| 28 |
+
|
| 29 |
+
BUILDER_CONFIGS = [
|
| 30 |
+
datasets.BuilderConfig(
|
| 31 |
+
name="withoutLabel",
|
| 32 |
+
description="",
|
| 33 |
+
version=VERSION,
|
| 34 |
+
),
|
| 35 |
+
|
| 36 |
+
datasets.BuilderConfig(
|
| 37 |
+
name="withLabel",
|
| 38 |
+
description="",
|
| 39 |
+
version=VERSION,
|
| 40 |
+
)
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
def _info(self):
|
| 44 |
+
return datasets.DatasetInfo(
|
| 45 |
+
description=_DESCRIPTION,
|
| 46 |
+
features=datasets.Features(
|
| 47 |
+
{
|
| 48 |
+
"text": datasets.Value("string"),
|
| 49 |
+
"label": datasets.Value("string")
|
| 50 |
+
}
|
| 51 |
+
),
|
| 52 |
+
supervised_keys=None,
|
| 53 |
+
homepage="https://github.com/usmaann/Depression_Severity_Dataset",
|
| 54 |
+
citation=_CITATION,
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
def _split_generators(self, dl_manager):
|
| 58 |
+
"""Returns SplitGenerators."""
|
| 59 |
+
data_dir = dl_manager.download_and_extract(_URLs)
|
| 60 |
+
|
| 61 |
+
return [
|
| 62 |
+
datasets.SplitGenerator(
|
| 63 |
+
name=datasets.Split.TRAIN,
|
| 64 |
+
gen_kwargs={
|
| 65 |
+
"filepath": data_dir["train"]
|
| 66 |
+
},
|
| 67 |
+
),
|
| 68 |
+
datasets.SplitGenerator(
|
| 69 |
+
name=datasets.Split.TEST,
|
| 70 |
+
gen_kwargs={
|
| 71 |
+
"filepath": data_dir["test"]
|
| 72 |
+
},
|
| 73 |
+
),
|
| 74 |
+
datasets.SplitGenerator(
|
| 75 |
+
name=datasets.Split.VALIDATION,
|
| 76 |
+
gen_kwargs={
|
| 77 |
+
"filepath": data_dir["valid"]
|
| 78 |
+
},
|
| 79 |
+
)
|
| 80 |
+
]
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def _generate_examples(self, filepath):
|
| 84 |
+
"""Yields examples."""
|
| 85 |
+
with open(filepath, encoding="utf-8") as input_file:
|
| 86 |
+
dataset = json.load(input_file)
|
| 87 |
+
idx = 0
|
| 88 |
+
for meta_data in dataset:
|
| 89 |
+
if self.config.name == "withoutLabel":
|
| 90 |
+
yield idx, meta_data["text"]
|
| 91 |
+
elif self.config.name == "withLabel":
|
| 92 |
+
yield idx, meta_data["text"], meta_data["label"]
|
| 93 |
+
else:
|
| 94 |
+
raise Exception("Not a Valid Config Name")
|
| 95 |
+
idx += 1
|