File size: 2,079 Bytes
8360c62
 
 
 
e9391a7
a69a697
 
 
 
 
 
 
 
8360c62
 
e9391a7
8360c62
 
 
 
 
 
 
 
 
64b9f55
 
8360c62
 
 
 
 
 
d58992b
8360c62
 
e9391a7
8360c62
 
 
 
 
 
64b9f55
 
 
 
 
 
8360c62
e9391a7
9221958
 
 
8360c62
 
 
 
 
 
e9391a7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Times of India News Headlines Dataset"""
import csv
import datasets

_CITATION = '''\\n@inproceedings{Casanueva2020,
    author      = Mulin,
    title       = Holiday Dataset,
    year        = {2022},
    month       = {Mar},
    note        = {},
    url         = {},
    booktitle   = {}
}'''

_DESCRIPTION = """\
This news dataset is a holiday information of singapore from 2017 to 2022.
"""

_DATE = "Date"
_DAY = "Day"
_HOLIDAY = "Holiday"

_HOMEPAGE = ""
_LICENSE = "MIT"

_TRAIN_DOWNLOAD_URL = 'https://raw.githubusercontent.com/ZhangLe59151/sg-dataset/main/holiday/holiday.csv'
_TEST_DOWNLOAD_URL = 'https://raw.githubusercontent.com/ZhangLe59151/sg-dataset/main/holiday/holiday.csv'


class TimesOfHoliday(datasets.GeneratorBasedBuilder):
    VERSION = datasets.Version("1.1.0")

    def _info(self):
        features = datasets.Features({_DATE: datasets.Value('string'), _DAY: datasets.Value('string'), _HOLIDAY: datasets.Value('string')})
        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            supervised_keys=None,
            homepage=_HOMEPAGE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager):
        train_path = dl_manager.download_and_extract(_TRAIN_DOWNLOAD_URL)
        test_path = dl_manager.download_and_extract(_TEST_DOWNLOAD_URL)
        return [
            datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": train_path}),
            datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": test_path})
            ]

    def _generate_examples(self, filepath):
        with open(filepath, encoding='utf-8') as f:
            csv_reader = csv.reader(f, quotechar='"', delimiter=",", quoting=csv.QUOTE_ALL, skipinitialspace=True)
            next(csv_reader)
            for id_, row in enumerate(csv_reader):
                Date, Day, Holiday = row
                yield id_, {
                    _DATE: str(Date),
                    _DAY: Day,
                    _HOLIDAY: Holiday,
                }