Commit
•
32a04d2
1
Parent(s):
8c69bb9
Enable dataset viewer by hosting data files (#2)
Browse files- Host data files (7bd3fa9ff4132bfbe0609813cc021585d35b86c2)
- Update loading script (bceaf96861dac37d68a292a1d51f83f47e4c4fec)
- Delete legacy metadata JSON file (2df9a65a59d2d09700524961b5322a002439c813)
data/GenericsKB-Best.tsv.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7653f9c9b79580b6b7b76b3320434259bca2c3f8d3e11bed26e8341ecbb8cf2c
|
3 |
+
size 27147920
|
data/GenericsKB-SimpleWiki-With-Context.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8808fa4dc532712438655dc96bf80caa4cdab0b897531f0fa26582d75ff46e21
|
3 |
+
size 2568536
|
data/GenericsKB-Waterloo-With-Context.jsonl.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b68d8e3818bc42268812748f37284b5af0997274b27586ed836918aec1cf84cc
|
3 |
+
size 1513320915
|
data/GenericsKB.tsv.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4aa5dfc906ce9a84ba12841ff91a796b7684e59e236362b09bf11bf9d0be7bd8
|
3 |
+
size 101859440
|
dataset_infos.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{"generics_kb_best": {"description": "The GenericsKB contains 3.4M+ generic sentences about the world, i.e., sentences expressing general truths such as \"Dogs bark,\" and \"Trees remove carbon dioxide from the atmosphere.\" Generics are potentially useful as a knowledge source for AI systems requiring general world knowledge. The GenericsKB is the first large-scale resource containing naturally occurring generic sentences (as opposed to extracted or crowdsourced triples), and is rich in high-quality, general, semantically complete statements. Generics were primarily extracted from three large text sources, namely the Waterloo Corpus, selected parts of Simple Wikipedia, and the ARC Corpus. A filtered, high-quality subset is also available in GenericsKB-Best, containing 1,020,868 sentences. We recommend you start with GenericsKB-Best.\n", "citation": "@InProceedings{huggingface:dataset,\ntitle = {GenericsKB: A Knowledge Base of Generic Statements},\nauthors={Sumithra Bhakthavatsalam, Chloe Anastasiades, Peter Clark},\nyear={2020},\npublisher = {Allen Institute for AI},\n}\n", "homepage": "https://allenai.org/data/genericskb", "license": "cc-by-4.0", "features": {"source": {"dtype": "string", "id": null, "_type": "Value"}, "term": {"dtype": "string", "id": null, "_type": "Value"}, "quantifier_frequency": {"dtype": "string", "id": null, "_type": "Value"}, "quantifier_number": {"dtype": "string", "id": null, "_type": "Value"}, "generic_sentence": {"dtype": "string", "id": null, "_type": "Value"}, "score": {"dtype": "float64", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "generics_kb", "config_name": "generics_kb_best", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 99897719, "num_examples": 1020868, "dataset_name": "generics_kb"}}, "download_checksums": {"https://drive.google.com/u/0/uc?id=12DfIzoWyHIQqssgUgDvz3VG8_ScSh6ng&export=download": {"num_bytes": 94850525, "checksum": "0668b23c8b1579b6a76fcf48e04f3c9ea039ca9048a26848151d689deabb75e2"}}, "download_size": 94850525, "post_processing_size": null, "dataset_size": 99897719, "size_in_bytes": 194748244}, "generics_kb": {"description": "The GenericsKB contains 3.4M+ generic sentences about the world, i.e., sentences expressing general truths such as \"Dogs bark,\" and \"Trees remove carbon dioxide from the atmosphere.\" Generics are potentially useful as a knowledge source for AI systems requiring general world knowledge. The GenericsKB is the first large-scale resource containing naturally occurring generic sentences (as opposed to extracted or crowdsourced triples), and is rich in high-quality, general, semantically complete statements. Generics were primarily extracted from three large text sources, namely the Waterloo Corpus, selected parts of Simple Wikipedia, and the ARC Corpus. A filtered, high-quality subset is also available in GenericsKB-Best, containing 1,020,868 sentences. We recommend you start with GenericsKB-Best.\n", "citation": "@InProceedings{huggingface:dataset,\ntitle = {GenericsKB: A Knowledge Base of Generic Statements},\nauthors={Sumithra Bhakthavatsalam, Chloe Anastasiades, Peter Clark},\nyear={2020},\npublisher = {Allen Institute for AI},\n}\n", "homepage": "https://allenai.org/data/genericskb", "license": "cc-by-4.0", "features": {"source": {"dtype": "string", "id": null, "_type": "Value"}, "term": {"dtype": "string", "id": null, "_type": "Value"}, "quantifier_frequency": {"dtype": "string", "id": null, "_type": "Value"}, "quantifier_number": {"dtype": "string", "id": null, "_type": "Value"}, "generic_sentence": {"dtype": "string", "id": null, "_type": "Value"}, "score": {"dtype": "float64", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "generics_kb", "config_name": "generics_kb", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 348158966, "num_examples": 3433000, "dataset_name": "generics_kb"}}, "download_checksums": {"https://drive.google.com/u/0/uc?id=1UOIEzQTid7SzKx2tbwSSPxl7g-CjpoZa&export=download": {"num_bytes": 343284785, "checksum": "7ec2419e700b3425129032f75f0bb01887bdb84231526468751d6cc2a9b9e61e"}}, "download_size": 343284785, "post_processing_size": null, "dataset_size": 348158966, "size_in_bytes": 691443751}, "generics_kb_simplewiki": {"description": "The GenericsKB contains 3.4M+ generic sentences about the world, i.e., sentences expressing general truths such as \"Dogs bark,\" and \"Trees remove carbon dioxide from the atmosphere.\" Generics are potentially useful as a knowledge source for AI systems requiring general world knowledge. The GenericsKB is the first large-scale resource containing naturally occurring generic sentences (as opposed to extracted or crowdsourced triples), and is rich in high-quality, general, semantically complete statements. Generics were primarily extracted from three large text sources, namely the Waterloo Corpus, selected parts of Simple Wikipedia, and the ARC Corpus. A filtered, high-quality subset is also available in GenericsKB-Best, containing 1,020,868 sentences. We recommend you start with GenericsKB-Best.\n", "citation": "@InProceedings{huggingface:dataset,\ntitle = {GenericsKB: A Knowledge Base of Generic Statements},\nauthors={Sumithra Bhakthavatsalam, Chloe Anastasiades, Peter Clark},\nyear={2020},\npublisher = {Allen Institute for AI},\n}\n", "homepage": "https://allenai.org/data/genericskb", "license": "cc-by-4.0", "features": {"source_name": {"dtype": "string", "id": null, "_type": "Value"}, "sentence": {"dtype": "string", "id": null, "_type": "Value"}, "sentences_before": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "sentences_after": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "concept_name": {"dtype": "string", "id": null, "_type": "Value"}, "quantifiers": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "bert_score": {"dtype": "float64", "id": null, "_type": "Value"}, "headings": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "categories": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}}, "post_processed": null, "supervised_keys": null, "builder_name": "generics_kb", "config_name": "generics_kb_simplewiki", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 10039355, "num_examples": 12765, "dataset_name": "generics_kb"}}, "download_checksums": {"https://drive.google.com/u/0/uc?id=1SpN9Qc7XRy5xs4tIfXkcLOEAP2IVaK15&export=download": {"num_bytes": 16437369, "checksum": "f6c0da9c9100172e8979907448497717d8ea1a50ee96aa2b81e447423c6cd0bb"}}, "download_size": 16437369, "post_processing_size": null, "dataset_size": 10039355, "size_in_bytes": 26476724}, "generics_kb_waterloo": {"description": "The GenericsKB contains 3.4M+ generic sentences about the world, i.e., sentences expressing general truths such as \"Dogs bark,\" and \"Trees remove carbon dioxide from the atmosphere.\" Generics are potentially useful as a knowledge source for AI systems requiring general world knowledge. The GenericsKB is the first large-scale resource containing naturally occurring generic sentences (as opposed to extracted or crowdsourced triples), and is rich in high-quality, general, semantically complete statements. Generics were primarily extracted from three large text sources, namely the Waterloo Corpus, selected parts of Simple Wikipedia, and the ARC Corpus. A filtered, high-quality subset is also available in GenericsKB-Best, containing 1,020,868 sentences. We recommend you start with GenericsKB-Best.\n", "citation": "@InProceedings{huggingface:dataset,\ntitle = {GenericsKB: A Knowledge Base of Generic Statements},\nauthors={Sumithra Bhakthavatsalam, Chloe Anastasiades, Peter Clark},\nyear={2020},\npublisher = {Allen Institute for AI},\n}\n", "homepage": "https://allenai.org/data/genericskb", "license": "cc-by-4.0", "features": {"source_name": {"dtype": "string", "id": null, "_type": "Value"}, "sentence": {"dtype": "string", "id": null, "_type": "Value"}, "sentences_before": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "sentences_after": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "concept_name": {"dtype": "string", "id": null, "_type": "Value"}, "quantifiers": {"feature": {"dtype": "string", "id": null, "_type": "Value"}, "length": -1, "id": null, "_type": "Sequence"}, "id": {"dtype": "string", "id": null, "_type": "Value"}, "bert_score": {"dtype": "float64", "id": null, "_type": "Value"}}, "post_processed": null, "supervised_keys": null, "builder_name": "generics_kb", "config_name": "generics_kb_waterloo", "version": {"version_str": "1.0.0", "description": null, "major": 1, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 4277214701, "num_examples": 3666725, "dataset_name": "generics_kb"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 4277214701, "size_in_bytes": 4277214701}}
|
|
|
|
generics_kb.py
CHANGED
@@ -17,7 +17,6 @@
|
|
17 |
|
18 |
import ast
|
19 |
import csv
|
20 |
-
import os
|
21 |
|
22 |
import datasets
|
23 |
|
@@ -41,13 +40,13 @@ _HOMEPAGE = "https://allenai.org/data/genericskb"
|
|
41 |
|
42 |
_LICENSE = "cc-by-4.0"
|
43 |
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
"generics_kb_best":
|
48 |
-
"generics_kb":
|
49 |
-
"generics_kb_simplewiki":
|
50 |
-
"generics_kb_waterloo": "
|
51 |
}
|
52 |
|
53 |
|
@@ -60,7 +59,7 @@ class GenericsKb(datasets.GeneratorBasedBuilder):
|
|
60 |
datasets.BuilderConfig(
|
61 |
name="generics_kb_best",
|
62 |
version=VERSION,
|
63 |
-
description="This is the default and recommended config.Comprises of GENERICSKB generics with a score > 0.234 ",
|
64 |
),
|
65 |
datasets.BuilderConfig(
|
66 |
name="generics_kb", version=VERSION, description="This GENERICSKB that contains 3,433,000 sentences."
|
@@ -77,30 +76,10 @@ class GenericsKb(datasets.GeneratorBasedBuilder):
|
|
77 |
),
|
78 |
]
|
79 |
|
80 |
-
@property
|
81 |
-
def manual_download_instructions(self):
|
82 |
-
return """\
|
83 |
-
You need to manually download the files needed for the dataset config generics_kb_waterloo. The other configs like generics_kb_best don't need manual downloads.
|
84 |
-
The <path/to/folder> can e.g. be `~/Downloads/GenericsKB`. Download the following required files from https://drive.google.com/drive/folders/1vqfVXhJXJWuiiXbUa4rZjOgQoJvwZUoT
|
85 |
-
For working on "generics_kb_waterloo" data,
|
86 |
-
1. Manually download 'GenericsKB-Waterloo-WithContext.jsonl.zip' into your <path/to/folder>.Please ensure the filename is as is.
|
87 |
-
The Waterloo is also generics from GenericsKB.tsv, but expanded to also include their surrounding context (before/after sentences). The Waterloo generics are the majority of GenericsKB. This zip file is 1.4GB expanding to 5.5GB.
|
88 |
-
2. Extract the GenericsKB-Waterloo-WithContext.jsonl.zip; It will create a file of 5.5 GB called cskb-waterloo-06-21-with-bert-scores.jsonl.
|
89 |
-
Ensure you move this file into your <path/to/folder>.
|
90 |
-
|
91 |
-
generics_kb can then be loaded using the following commands based on which data you want to work on. Data files must be present in the <path/to/folder> if using "generics_kb_waterloo" config.
|
92 |
-
1. `datasets.load_dataset("generics_kb","generics_kb_best")`.
|
93 |
-
2. `datasets.load_dataset("generics_kb","generics_kb")`
|
94 |
-
3. `datasets.load_dataset("generics_kb","generics_kb_simplewiki")`
|
95 |
-
4. `datasets.load_dataset("generics_kb","generics_kb_waterloo", data_dir="<path/to/folder>")`
|
96 |
-
|
97 |
-
"""
|
98 |
-
|
99 |
DEFAULT_CONFIG_NAME = "generics_kb_best"
|
100 |
|
101 |
def _info(self):
|
102 |
if self.config.name == "generics_kb_waterloo" or self.config.name == "generics_kb_simplewiki":
|
103 |
-
|
104 |
featuredict = {
|
105 |
"source_name": datasets.Value("string"),
|
106 |
"sentence": datasets.Value("string"),
|
@@ -118,7 +97,6 @@ class GenericsKb(datasets.GeneratorBasedBuilder):
|
|
118 |
features = datasets.Features(featuredict)
|
119 |
|
120 |
else:
|
121 |
-
|
122 |
features = datasets.Features(
|
123 |
{
|
124 |
"source": datasets.Value("string"),
|
@@ -148,24 +126,7 @@ class GenericsKb(datasets.GeneratorBasedBuilder):
|
|
148 |
)
|
149 |
|
150 |
def _split_generators(self, dl_manager):
|
151 |
-
|
152 |
-
if self.config.name == "generics_kb_waterloo":
|
153 |
-
data_dir = os.path.abspath(os.path.expanduser(dl_manager.manual_dir))
|
154 |
-
# check if manual folder exists
|
155 |
-
if not os.path.exists(data_dir):
|
156 |
-
raise FileNotFoundError(
|
157 |
-
f"{data_dir} does not exist. Make sure you insert a manual dir via `datasets.load_dataset('generics_kb', data_dir=...)`. Manual download instructions: {self.manual_download_instructions})"
|
158 |
-
)
|
159 |
-
|
160 |
-
# Check if required files exist in the folder
|
161 |
-
filepath = os.path.join(data_dir, _FILEPATHS[self.config.name])
|
162 |
-
|
163 |
-
if not os.path.exists(filepath):
|
164 |
-
raise FileNotFoundError(
|
165 |
-
f"{filepath} does not exist. Make sure you required files are present in {data_dir} `. Manual download instructions: {self.manual_download_instructions})"
|
166 |
-
)
|
167 |
-
else:
|
168 |
-
filepath = dl_manager.download(_FILEPATHS[self.config.name])
|
169 |
|
170 |
return [
|
171 |
datasets.SplitGenerator(
|
@@ -181,7 +142,6 @@ class GenericsKb(datasets.GeneratorBasedBuilder):
|
|
181 |
"""Yields examples."""
|
182 |
|
183 |
if self.config.name == "generics_kb_waterloo" or self.config.name == "generics_kb_simplewiki":
|
184 |
-
|
185 |
with open(filepath, encoding="utf-8") as f:
|
186 |
for id_, row in enumerate(f):
|
187 |
data = ast.literal_eval(row)
|
@@ -202,7 +162,6 @@ class GenericsKb(datasets.GeneratorBasedBuilder):
|
|
202 |
|
203 |
yield id_, result
|
204 |
else:
|
205 |
-
|
206 |
with open(filepath, encoding="utf-8") as f:
|
207 |
# Skip the header
|
208 |
next(f)
|
@@ -210,7 +169,6 @@ class GenericsKb(datasets.GeneratorBasedBuilder):
|
|
210 |
read_tsv = csv.reader(f, delimiter="\t")
|
211 |
|
212 |
for id_, row in enumerate(read_tsv):
|
213 |
-
|
214 |
quantifier = row[2]
|
215 |
quantifier_frequency = ""
|
216 |
quantifier_number = ""
|
|
|
17 |
|
18 |
import ast
|
19 |
import csv
|
|
|
20 |
|
21 |
import datasets
|
22 |
|
|
|
40 |
|
41 |
_LICENSE = "cc-by-4.0"
|
42 |
|
43 |
+
_BASE_URL = "data/{0}"
|
44 |
|
45 |
+
_URLS = {
|
46 |
+
"generics_kb_best": _BASE_URL.format("GenericsKB-Best.tsv.gz"),
|
47 |
+
"generics_kb": _BASE_URL.format("GenericsKB.tsv.gz"),
|
48 |
+
"generics_kb_simplewiki": _BASE_URL.format("GenericsKB-SimpleWiki-With-Context.jsonl.gz"),
|
49 |
+
"generics_kb_waterloo": _BASE_URL.format("GenericsKB-Waterloo-With-Context.jsonl.gz"),
|
50 |
}
|
51 |
|
52 |
|
|
|
59 |
datasets.BuilderConfig(
|
60 |
name="generics_kb_best",
|
61 |
version=VERSION,
|
62 |
+
description="This is the default and recommended config. Comprises of GENERICSKB generics with a score > 0.234 ",
|
63 |
),
|
64 |
datasets.BuilderConfig(
|
65 |
name="generics_kb", version=VERSION, description="This GENERICSKB that contains 3,433,000 sentences."
|
|
|
76 |
),
|
77 |
]
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
DEFAULT_CONFIG_NAME = "generics_kb_best"
|
80 |
|
81 |
def _info(self):
|
82 |
if self.config.name == "generics_kb_waterloo" or self.config.name == "generics_kb_simplewiki":
|
|
|
83 |
featuredict = {
|
84 |
"source_name": datasets.Value("string"),
|
85 |
"sentence": datasets.Value("string"),
|
|
|
97 |
features = datasets.Features(featuredict)
|
98 |
|
99 |
else:
|
|
|
100 |
features = datasets.Features(
|
101 |
{
|
102 |
"source": datasets.Value("string"),
|
|
|
126 |
)
|
127 |
|
128 |
def _split_generators(self, dl_manager):
|
129 |
+
filepath = dl_manager.download_and_extract(_URLS[self.config.name])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
|
131 |
return [
|
132 |
datasets.SplitGenerator(
|
|
|
142 |
"""Yields examples."""
|
143 |
|
144 |
if self.config.name == "generics_kb_waterloo" or self.config.name == "generics_kb_simplewiki":
|
|
|
145 |
with open(filepath, encoding="utf-8") as f:
|
146 |
for id_, row in enumerate(f):
|
147 |
data = ast.literal_eval(row)
|
|
|
162 |
|
163 |
yield id_, result
|
164 |
else:
|
|
|
165 |
with open(filepath, encoding="utf-8") as f:
|
166 |
# Skip the header
|
167 |
next(f)
|
|
|
169 |
read_tsv = csv.reader(f, delimiter="\t")
|
170 |
|
171 |
for id_, row in enumerate(read_tsv):
|
|
|
172 |
quantifier = row[2]
|
173 |
quantifier_frequency = ""
|
174 |
quantifier_number = ""
|