Mulin commited on
Commit
8360c62
1 Parent(s): d40e063

Upload sg-holiday.py

Browse files
Files changed (1) hide show
  1. sg-holiday.py +62 -0
sg-holiday.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Times of India News Headlines Dataset"""
2
+ import csv
3
+ import os
4
+ import datasets
5
+
6
+ _CITATION = """\
7
+ @data{DVN/DPQMQH_2022,
8
+ author = {Mulin},
9
+ publisher = {Mulin},
10
+ title = {{holiday dataset}},
11
+ year = {2022},
12
+ version = {V1},
13
+ url = {https://huggingface.co/datasets/Mulin/sg-holiday}
14
+ }
15
+ """
16
+
17
+ _DESCRIPTION = """\
18
+ This news dataset is a holiday information of singapore from 2017 to 2022.
19
+ """
20
+
21
+ _DATE = "Date"
22
+ _DAY = "Day"
23
+ _HOLIDAY = "Holiday"
24
+
25
+ _HOMEPAGE = ""
26
+ _LICENSE = "MIT"
27
+
28
+ _FILENAME = "holiday.csv"
29
+
30
+
31
+ class TimesOfHoliday(datasets.GeneratorBasedBuilder):
32
+ VERSION = datasets.Version("1.1.0")
33
+
34
+ def _info(self):
35
+ feature_names = [_DATE, _DAY, _HOLIDAY]
36
+ return datasets.DatasetInfo(
37
+ description=_DESCRIPTION,
38
+ features=datasets.Features(feature_names),
39
+ supervised_keys=None,
40
+ homepage=_HOMEPAGE,
41
+ citation=_CITATION,
42
+ )
43
+
44
+ def _split_generators(self, dl_manager):
45
+ """Returns SplitGenerators."""
46
+ path_to_manual_file = os.path.join(os.path.abspath(os.path.expanduser(dl_manager.manual_dir)), _FILENAME)
47
+ return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"path": path_to_manual_file})]
48
+
49
+ def _generate_examples(self, path=None):
50
+ """Yields examples."""
51
+ with open(path, encoding="utf8") as csv_file:
52
+ csv_reader = csv.reader(
53
+ csv_file, quotechar='"', delimiter=",", skipinitialspace=True, quoting=csv.QUOTE_ALL
54
+ )
55
+ for id_, row in enumerate(csv_reader):
56
+ Date, Day, Holiday = row
57
+ yield id_, {
58
+ _DATE: str(Date),
59
+ _DAY: Day,
60
+ _HOLIDAY: Holiday,
61
+ }
62
+