Upload medical_institutions_reviews.py
Browse files
medical_institutions_reviews.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datasets
|
2 |
+
import json
|
3 |
+
|
4 |
+
class HfreviewsConfig(datasets.BuilderConfig):
|
5 |
+
def __init__(self, features, **kwargs):
|
6 |
+
super(HfreviewsConfig, self).__init__(version=datasets.Version("1.0.0", ""), **kwargs)
|
7 |
+
self.features = features
|
8 |
+
|
9 |
+
class MedicalInstitutionsReviews(datasets.GeneratorBasedBuilder):
|
10 |
+
BUILDER_CONFIGS = [
|
11 |
+
HfreviewsConfig(
|
12 |
+
name="simple",
|
13 |
+
description="Simple config",
|
14 |
+
features=["content", "title", "sentiment", "category", "review_id", "source_url"],
|
15 |
+
)
|
16 |
+
]
|
17 |
+
|
18 |
+
def _info(self):
|
19 |
+
return datasets.DatasetInfo(
|
20 |
+
description='Healthcare facilities reviews dataset.',
|
21 |
+
features=datasets.Features(
|
22 |
+
{
|
23 |
+
"review_id": datasets.Value("string"),
|
24 |
+
"content": datasets.Value("string"),
|
25 |
+
"general": datasets.Value("string"),
|
26 |
+
"quality": datasets.Value("string"),
|
27 |
+
"service": datasets.Value("string"),
|
28 |
+
"equipment": datasets.Value("string"),
|
29 |
+
"food": datasets.Value("string"),
|
30 |
+
"location": datasets.Value("string"),
|
31 |
+
"Idx": datasets.Value("int32"),
|
32 |
+
}
|
33 |
+
),
|
34 |
+
supervised_keys=None,
|
35 |
+
homepage='',
|
36 |
+
)
|
37 |
+
|
38 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
39 |
+
urls_to_download = {
|
40 |
+
"train": "medical_institutions_reviews.jsonl"
|
41 |
+
}
|
42 |
+
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
43 |
+
|
44 |
+
return [
|
45 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]})
|
46 |
+
]
|
47 |
+
|
48 |
+
def _generate_examples(self, filepath):
|
49 |
+
"""Yields examples."""
|
50 |
+
with open(filepath, encoding="utf-8") as f:
|
51 |
+
for uid, row in enumerate(f):
|
52 |
+
data = json.loads(row)
|
53 |
+
data["Idx"] = uid
|
54 |
+
yield uid, data
|