Datasets:
andreaschandra
commited on
Commit
•
c954c92
1
Parent(s):
2456414
add path
Browse files- causalqa.py +26 -22
causalqa.py
CHANGED
@@ -32,7 +32,7 @@ class CausalqaConfig(datasets.BuilderConfig):
|
|
32 |
self.data_url = data_url
|
33 |
self.citation = citation
|
34 |
|
35 |
-
def OneBuild(data_info,feat_meta):
|
36 |
main_name = [*data_info][0]
|
37 |
submain_name = data_info[main_name].keys()
|
38 |
all_config = []
|
@@ -50,39 +50,43 @@ def OneBuild(data_info,feat_meta):
|
|
50 |
all_config.append(cqa_config)
|
51 |
return all_config
|
52 |
|
53 |
-
_PATH_SOURCE = 'source'
|
54 |
-
_PATH_METADATA = os.path.join(_PATH_SOURCE, 'features_metadata.yaml')
|
55 |
-
_PATH_DATASET = os.path.join(_PATH_SOURCE, 'dataset_info.json')
|
56 |
-
_PATH_DESCRIPTION = os.path.join(_PATH_SOURCE, 'dataset_description.txt')
|
57 |
|
58 |
-
datasets.
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
63 |
|
64 |
-
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
77 |
|
78 |
def _info(self):
|
79 |
self.features = {feat: datasets.Value(self.config.data_features[feat])
|
80 |
for feat in self.config.data_features}
|
81 |
|
82 |
return datasets.DatasetInfo(
|
83 |
-
description=_CAUSALQA_DESCRIPTION,
|
84 |
features=datasets.Features(self.features),
|
85 |
-
homepage=_HOMEPAGE
|
86 |
)
|
87 |
|
88 |
def _split_generators(self, dl_manager):
|
|
|
32 |
self.data_url = data_url
|
33 |
self.citation = citation
|
34 |
|
35 |
+
def OneBuild(data_info, feat_meta):
|
36 |
main_name = [*data_info][0]
|
37 |
submain_name = data_info[main_name].keys()
|
38 |
all_config = []
|
|
|
50 |
all_config.append(cqa_config)
|
51 |
return all_config
|
52 |
|
|
|
|
|
|
|
|
|
53 |
|
54 |
+
class CausalQA(datasets.GeneratorBasedBuilder):
|
55 |
+
"""CausalQA: An QA causal type dataset."""
|
56 |
|
57 |
+
def __init__(self, dl_manager):
|
58 |
+
self._PATH_SOURCE = 'source'
|
59 |
+
self._PATH_METADATA = os.path.join(self._PATH_SOURCE, 'features_metadata.yaml')
|
60 |
+
self._PATH_DATASET = os.path.join(self._PATH_SOURCE, 'dataset_info.json')
|
61 |
+
self._PATH_DESCRIPTION = os.path.join(self._PATH_SOURCE, 'dataset_description.txt')
|
62 |
|
63 |
+
dl_manager.download([self._PATH_METADATA, self._PATH_DATASET, self._PATH_DESCRIPTION])
|
64 |
|
65 |
+
self._FILE_URL = json.load(open(self._PATH_DATASET))
|
66 |
+
self._CAUSALQA_DESCRIPTION = ''.join(open(self._PATH_DESCRIPTION).readlines())
|
67 |
+
self._HOMEPAGE = self._FILE_URL['homepage']
|
68 |
+
|
69 |
+
all_files = self._FILE_URL['files']
|
70 |
+
|
71 |
+
with open(self._PATH_METADATA, "r") as stream:
|
72 |
+
try:
|
73 |
+
fmeta = yaml.safe_load(stream)
|
74 |
+
except yaml.YAMLError as exc:
|
75 |
+
print(exc)
|
76 |
|
77 |
+
BUILDER_CONFIGS = []
|
78 |
+
for f in all_files:
|
79 |
+
BUILDER_CONFIGS += (OneBuild(f, fmeta))
|
80 |
+
|
81 |
|
82 |
def _info(self):
|
83 |
self.features = {feat: datasets.Value(self.config.data_features[feat])
|
84 |
for feat in self.config.data_features}
|
85 |
|
86 |
return datasets.DatasetInfo(
|
87 |
+
description=self._CAUSALQA_DESCRIPTION,
|
88 |
features=datasets.Features(self.features),
|
89 |
+
homepage=self._HOMEPAGE
|
90 |
)
|
91 |
|
92 |
def _split_generators(self, dl_manager):
|