blinoff commited on
Commit
94bfbe1
1 Parent(s): 1c52eab

Upload healthcare_facilities_reviews.py

Browse files
Files changed (1) hide show
  1. healthcare_facilities_reviews.py +56 -0
healthcare_facilities_reviews.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import pandas as pd
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 HealthcareFacilitiesReviews(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
+ "content": datasets.Value("string"),
24
+ "title": datasets.Value("string"),
25
+ "sentiment": datasets.Value("string"),
26
+ "category": datasets.Value("string"),
27
+ "review_id": datasets.Value("string"),
28
+ "source_url": datasets.Value("string"),
29
+ "Idx": datasets.Value("int32"),
30
+ }
31
+ ),
32
+ supervised_keys=None,
33
+ homepage='',
34
+ )
35
+
36
+ def _split_generators(self, dl_manager: datasets.DownloadManager):
37
+ urls_to_download = {
38
+ "train": "healthcare_facilities_reviews.jsonl",
39
+ "dev": "healthcare_facilities_reviews.jsonl",
40
+ }
41
+ downloaded_files = dl_manager.download_and_extract(urls_to_download)
42
+
43
+ return [
44
+ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
45
+ datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["dev"]}),
46
+ ]
47
+
48
+ def _generate_examples(self, filepath):
49
+ df = pd.read_json(filepath, lines=True)
50
+ rows = df.to_dict(orient="records")
51
+
52
+ for n, row in enumerate(rows):
53
+ example = row
54
+ example["Idx"] = n
55
+
56
+ yield example["Idx"], example