patrickocal commited on
Commit
4e7796b
·
verified ·
1 Parent(s): 0cd4f42

kg combined data files

Browse files
.gitattributes CHANGED
@@ -56,6 +56,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
56
  gov_report_kg/test.jsonl.zip filter=lfs diff=lfs merge=lfs -text
57
  gov_report_kg/train.jsonl.zip filter=lfs diff=lfs merge=lfs -text
58
  gov_report_kg/validation.jsonl.zip filter=lfs diff=lfs merge=lfs -text
59
- gov_report_kg_dots/test.jsonl.zip filter=lfs diff=lfs merge=lfs -text
60
- gov_report_kg_dots/train.jsonl.zip filter=lfs diff=lfs merge=lfs -text
61
- gov_report_kg_dots/validation.jsonl.zip filter=lfs diff=lfs merge=lfs -text
 
56
  gov_report_kg/test.jsonl.zip filter=lfs diff=lfs merge=lfs -text
57
  gov_report_kg/train.jsonl.zip filter=lfs diff=lfs merge=lfs -text
58
  gov_report_kg/validation.jsonl.zip filter=lfs diff=lfs merge=lfs -text
59
+ gov_report_kg_comb/test.jsonl.zip filter=lfs diff=lfs merge=lfs -text
60
+ gov_report_kg_comb/train.jsonl.zip filter=lfs diff=lfs merge=lfs -text
61
+ gov_report_kg_comb/validation.jsonl.zip filter=lfs diff=lfs merge=lfs -text
dormant_loading_script.py ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # TODO: Address all TODOs and remove all explanatory comments
15
+ """TODO: Add a description here."""
16
+
17
+
18
+ import csv
19
+ import json
20
+ import os
21
+
22
+ import datasets
23
+
24
+
25
+ # TODO: Add BibTeX citation
26
+ # Find for instance the citation on arxiv or on the dataset repo/website
27
+ _CITATION = """\
28
+ @InProceedings{huggingface:dataset,
29
+ title = {A great new dataset},
30
+ author={huggingface, Inc.
31
+ },
32
+ year={2020}
33
+ }
34
+ """
35
+
36
+ # TODO: Add description of the dataset here
37
+ # You can copy an official description
38
+ _DESCRIPTION = """\
39
+ This new dataset is designed to solve this great NLP task and is crafted with a lot of care.
40
+ """
41
+
42
+ # TODO: Add a link to an official homepage for the dataset here
43
+ _HOMEPAGE = "https://huggingface.co/datasets/patrickocal/gov_report_kg"
44
+
45
+ # TODO: Add the licence for the dataset here if you can find it
46
+ _LICENSE = "MIT"
47
+
48
+ # TODO: Add link to the official dataset URLs here
49
+ # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
50
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
51
+ _URLS = {
52
+ "gov_report_kg": "https://huggingface.co/datasets/patrickocal/gov_report_kg/blob/main/gov_report_kg.zip",
53
+ #--- "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
54
+ }
55
+
56
+
57
+ # TODO: Name of the dataset usually matches the script name with CamelCase instead of snake_case
58
+ class GovReportKGs(datasets.GeneratorBasedBuilder):
59
+ """TODO: Short description of my dataset."""
60
+
61
+ VERSION = datasets.Version("1.1.0")
62
+
63
+ # This is an example of a dataset with multiple configurations.
64
+ # If you don't want/need to define several sub-sets in your dataset,
65
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
66
+
67
+ # If you need to make complex sub-parts in the datasets with configurable options
68
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
69
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
70
+
71
+ # You will be able to load one or the other configurations in the following list with
72
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
73
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
74
+ BUILDER_CONFIGS = [
75
+ datasets.BuilderConfig(name="gov_report_kg", version=VERSION, description="This part of my dataset covers a first domain")
76
+ #--- datasets.BuilderConfig(name="second_domain", version=VERSION, description="This part of my dataset covers a second domain"),
77
+ ]
78
+
79
+ #--- DEFAULT_CONFIG_NAME = "first_domain" # It's not mandatory to have a default configuration. Just use one if it make sense.
80
+
81
+ def _info(self):
82
+ # TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
83
+ if self.config.name == "gov_report_kg": # This is the name of the configuration selected in BUILDER_CONFIGS above
84
+ features = datasets.Features(
85
+ {
86
+ "id": datasets.Value("string"),
87
+ "pid": datasets.Value("string"),
88
+ "input": datasets.Value("string"),
89
+ "output": datasets.Value("string"),
90
+ # These are the features of your dataset like images, labels ...
91
+ }
92
+ )
93
+ #--- else: # This is an example to show how to have different features for "first_domain" and "second_domain"
94
+ #--- features = datasets.Features(
95
+ #--- {
96
+ #--- "sentence": datasets.Value("string"),
97
+ #--- "option2": datasets.Value("string"),
98
+ #--- "second_domain_answer": datasets.Value("string")
99
+ #--- # These are the features of your dataset like images, labels ...
100
+ #--- }
101
+ #--- )
102
+ return datasets.DatasetInfo(
103
+ # This is the description that will appear on the datasets page.
104
+ description=_DESCRIPTION,
105
+ # This defines the different columns of the dataset and their types
106
+ features=features, # Here we define them above because they are different between the two configurations
107
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
108
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
109
+ # supervised_keys=("sentence", "label"),
110
+ # Homepage of the dataset for documentation
111
+ homepage=_HOMEPAGE,
112
+ # License for the dataset if available
113
+ license=_LICENSE,
114
+ # Citation for the dataset
115
+ citation=_CITATION,
116
+ )
117
+
118
+ def _split_generators(self, dl_manager):
119
+ # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
120
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
121
+
122
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
123
+ # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
124
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
125
+ urls = _URLS[self.config.name]
126
+ data_dir = dl_manager.download_and_extract(urls)
127
+ return [
128
+ datasets.SplitGenerator(
129
+ name=datasets.Split.TRAIN,
130
+ # These kwargs will be passed to _generate_examples
131
+ gen_kwargs={
132
+ "filepath": os.path.join(data_dir, "train.jsonl"),
133
+ "split": "train",
134
+ },
135
+ ),
136
+ datasets.SplitGenerator(
137
+ name=datasets.Split.VALIDATION,
138
+ # These kwargs will be passed to _generate_examples
139
+ gen_kwargs={
140
+ "filepath": os.path.join(data_dir, "validation.jsonl"),
141
+ "split": "validation",
142
+ },
143
+ ),
144
+ datasets.SplitGenerator(
145
+ name=datasets.Split.TEST,
146
+ # These kwargs will be passed to _generate_examples
147
+ gen_kwargs={
148
+ "filepath": os.path.join(data_dir, "test.jsonl"),
149
+ "split": "test"
150
+ },
151
+ ),
152
+ ]
153
+
154
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
155
+ def _generate_examples(self, filepath, split):
156
+ # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
157
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
158
+ with open(filepath, encoding="utf-8") as f:
159
+ for key, row in enumerate(f):
160
+ data = json.loads(row)
161
+ if self.config.name == "gov_report_kg":
162
+ # Yields examples as (key, example) tuples
163
+ yield key, {
164
+ "id": data["id"],
165
+ "pid": data["pid"],
166
+ "input": data["input"],
167
+ "output": data["output"]
168
+ }
169
+ #--- else:
170
+ #--- yield key, {
171
+ #--- "sentence": data["sentence"],
172
+ #--- "option2": data["option2"],
173
+ #--- "second_domain_answer": "" if split == "test" else data["second_domain_answer"],
174
+ #--- }
{gov_report_kg_dots → gov_report_kg_comb}/test.jsonl.zip RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4afe76d350697bd366225c2ce5e8368513c5e9ef68978029e04aa8834b56b2c1
3
- size 2022712
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6097ba0f7b3e9000e9ebf095abc754acb0d855453dfeec183628dba59c95a299
3
+ size 16366634
{gov_report_kg_dots → gov_report_kg_comb}/train.jsonl.zip RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b72239851f58b55020195450ffbf29200d9c9a6b80059783dac519920c24984b
3
- size 56571432
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5d95b261d2441ec1775b2b172de336a3542b4b2a6d5fe6e15e593e33d330c00e
3
+ size 324163636
{gov_report_kg_dots → gov_report_kg_comb}/validation.jsonl.zip RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6ee58d56dc095c0eb029fea487bea2b120b47d6af2045ec4bbc51d4aaaed2d31
3
- size 3334157
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b61fa8715ba2559a6b5341c980650686055ea854dfce137acdc143b15576ab6
3
+ size 18666974