Datasets:

Languages:
Filipino
ArXiv:
License:
File size: 5,875 Bytes
72f4737
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
from pathlib import Path
from typing import Dict, List, Tuple

import datasets

try:
    import pyreadr
except:
    print("Install the `pyreadr` package to use.")

from seacrowd.utils import schemas
from seacrowd.utils.configs import SEACrowdConfig
from seacrowd.utils.constants import (TASK_TO_SCHEMA, Licenses, Tasks)

_DATASETNAME = "iatf"

_CITATION = """\
@misc{
   iatf,
   title={Inter-Agency Task Force for the Management of Emerging Infectious Diseases (IATF) COVID-19 Resolutions},
   url={https://como-ph.github.io/post/creating-text-data-from-iatf-resolutions/},
   author={Chris Mercado, John Robert Medina, Ernest Guevarra}
}
"""

_DESCRIPTION = """\
To assess possible impact of various COVID-19 prediction models on Philippine government response, text from various resolutions issued by
the Inter-agency Task Force for the Management of Emerging Infectious Diseases (IATF) has been collected using data mining approaches implemented in R.
"""

_HOMEPAGE = "https://github.com/como-ph/covidphtext/tree/master/data"

_LICENSE = Licenses.GPL_3_0.value

_SUPPORTED_TASKS = [Tasks.SELF_SUPERVISED_PRETRAINING]
_SEACROWD_SCHEMA_NAME = TASK_TO_SCHEMA[_SUPPORTED_TASKS[0]].lower()
_LANGUAGES = ["fil"]
_LOCAL = False
_SOURCE_VERSION = "1.0.0"
_SEACROWD_VERSION = "2024.06.20"

_URL_BASE = "https://github.com/como-ph/covidphtext/raw/master/data/"
_URLS = [
   "iatfGuidelineOmnibus.rda",
   "iatfResolution01.rda",
   "iatfResolution02.rda",
   "iatfResolution03.rda",
   "iatfResolution04.rda",
   "iatfResolution05.rda",
   "iatfResolution06.rda",
   "iatfResolution07.rda",
   "iatfResolution08.rda",
   "iatfResolution09.rda",
   "iatfResolution10.rda",
   "iatfResolution11.rda",
   "iatfResolution12.rda",
   "iatfResolution13.rda",
   "iatfResolution14.rda",
   "iatfResolution15.rda",
   "iatfResolution16.rda",
   "iatfResolution17.rda",
   "iatfResolution18.rda",
   "iatfResolution19.rda",
   "iatfResolution20.rda",
   "iatfResolution21.rda",
   "iatfResolution22.rda",
   "iatfResolution23.rda",
   "iatfResolution24.rda",
   "iatfResolution25.rda",
   "iatfResolution26.rda",
   "iatfResolution27.rda",
   "iatfResolution28.rda",
   "iatfResolution29.rda",
   "iatfResolution30.rda",
   "iatfResolution30A.rda",
   "iatfResolution31.rda",
   "iatfResolution32.rda",
   "iatfResolution33.rda",
   "iatfResolution34.rda",
   "iatfResolution35.rda",
   "iatfResolution36.rda",
   "iatfResolution37.rda",
   "iatfResolution38.rda",
   "iatfResolution39.rda",
   "iatfResolution40.rda",
   "iatfResolution41.rda",
   "iatfResolution42.rda",
   "iatfResolution43.rda",
   "iatfResolution44.rda",
   "iatfResolution45.rda",
   "iatfResolution46.rda",
   "iatfResolution46A.rda",
   "iatfResolution47.rda",
   "iatfResolution48.rda",
   "iatfResolution49.rda",
   "iatfResolution50.rda",
   "iatfResolution50A.rda",
   "iatfResolution51.rda",
   "iatfResolution52.rda",
   "iatfResolution53.rda",
   "iatfResolution54.rda",
   "iatfResolution55.rda",
   "iatfResolution55A.rda",
   "iatfResolution56.rda",
   "iatfResolution57.rda",
   "iatfResolution58.rda",
   "iatfResolution59.rda",
   "iatfResolution60.rda",
   "iatfResolution60A.rda",
]


class IATFDataset(datasets.GeneratorBasedBuilder):
    """Inter-agency Task Force for the Management of Emerging Infectious Diseases Dataset"""

    BUILDER_CONFIGS = [
        SEACrowdConfig(
            name=f"{_DATASETNAME}_source",
            version=datasets.Version(_SOURCE_VERSION),
            description=f"{_DATASETNAME} source schema",
            schema="source",
            subset_id=f"{_DATASETNAME}",
        ),
        SEACrowdConfig(
            name=f"{_DATASETNAME}_seacrowd_{_SEACROWD_SCHEMA_NAME}",
            version=datasets.Version(_SEACROWD_VERSION),
            description=f"{_DATASETNAME} seacrowd schema",
            schema=f"seacrowd_{_SEACROWD_SCHEMA_NAME}",
            subset_id=f"{_DATASETNAME}",
        ),
    ]

    DEFAULT_CONFIG_NAME = f"{_DATASETNAME}_source"

    def _info(self) -> datasets.DatasetInfo:
        if self.config.schema == "source":
            features = datasets.Features(
                {
                    "id": datasets.Value("string"),
                    "text": datasets.Value("string"),
                }
            )
        elif self.config.schema == f"seacrowd_{_SEACROWD_SCHEMA_NAME}":
            features = schemas.self_supervised_pretraining.features
        else:
            raise ValueError(f"Invalid config schema: {self.config.schema}")

        return datasets.DatasetInfo(
            description=_DESCRIPTION,
            features=features,
            homepage=_HOMEPAGE,
            license=_LICENSE,
            citation=_CITATION,
        )

    def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
        filepaths = [Path(dl_manager.download(_URL_BASE + url)) for url in _URLS]
        return [
            datasets.SplitGenerator(
                name=datasets.Split.TRAIN,
                gen_kwargs={"filepaths": filepaths},
            ),
        ]

    def _generate_examples(self, filepaths: List[Path]) -> Tuple[int, Dict]:
        counter = 0
        for path in filepaths:
            data = pyreadr.read_r(path)
            text = " ".join([str(x) for x in data[list(data.keys())[0]]["text"].values])
            if self.config.schema == "source":
                yield (
                    counter,
                    {
                        "id": str(counter),
                        "text": text.strip(),
                    },
                )
            elif self.config.schema == f"seacrowd_{_SEACROWD_SCHEMA_NAME}":
                yield (
                    counter,
                    {
                        "id": str(counter),
                        "text": text.strip(),
                    },
                )

            counter += 1