Commit
•
ea62e45
0
Parent(s):
Update files from the datasets library (from 1.2.0)
Browse filesRelease notes: https://github.com/huggingface/datasets/releases/tag/1.2.0
- .gitattributes +27 -0
- README.md +195 -0
- dataset_infos.json +1 -0
- dummy/generics_kb/1.0.0/dummy_data.zip +3 -0
- dummy/generics_kb_best/1.0.0/dummy_data.zip +3 -0
- dummy/generics_kb_simplewiki/1.0.0/dummy_data.zip +3 -0
- dummy/generics_kb_waterloo/1.0.0/dummy_data.zip +3 -0
- generics_kb.py +232 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
20 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
annotations_creators:
|
3 |
+
- machine-generated
|
4 |
+
language_creators:
|
5 |
+
- found
|
6 |
+
languages:
|
7 |
+
- en
|
8 |
+
licenses:
|
9 |
+
- cc-by-4-0
|
10 |
+
multilinguality:
|
11 |
+
- monolingual
|
12 |
+
size_categories:
|
13 |
+
- n>1M
|
14 |
+
source_datasets:
|
15 |
+
- original
|
16 |
+
task_categories:
|
17 |
+
- other
|
18 |
+
task_ids:
|
19 |
+
- other-other-knowledge-base
|
20 |
+
---
|
21 |
+
|
22 |
+
# Dataset Card for Generics KB
|
23 |
+
|
24 |
+
## Table of Contents
|
25 |
+
- [Dataset Description](#dataset-description)
|
26 |
+
- [Dataset Summary](#dataset-summary)
|
27 |
+
- [Supported Tasks](#supported-tasks-and-leaderboards)
|
28 |
+
- [Languages](#languages)
|
29 |
+
- [Dataset Structure](#dataset-structure)
|
30 |
+
- [Data Instances](#data-instances)
|
31 |
+
- [Data Fields](#data-fields)
|
32 |
+
- [Data Splits](#data-splits)
|
33 |
+
- [Dataset Creation](#dataset-creation)
|
34 |
+
- [Curation Rationale](#curation-rationale)
|
35 |
+
- [Source Data](#source-data)
|
36 |
+
- [Annotations](#annotations)
|
37 |
+
- [Personal and Sensitive Information](#personal-and-sensitive-information)
|
38 |
+
- [Considerations for Using the Data](#considerations-for-using-the-data)
|
39 |
+
- [Social Impact of Dataset](#social-impact-of-dataset)
|
40 |
+
- [Discussion of Biases](#discussion-of-biases)
|
41 |
+
- [Other Known Limitations](#other-known-limitations)
|
42 |
+
- [Additional Information](#additional-information)
|
43 |
+
- [Dataset Curators](#dataset-curators)
|
44 |
+
- [Licensing Information](#licensing-information)
|
45 |
+
- [Citation Information](#citation-information)
|
46 |
+
|
47 |
+
## Dataset Description
|
48 |
+
|
49 |
+
- **Homepage:** [Homepage](https://allenai.org/data/genericskb)
|
50 |
+
- **Repository:** [Repository](https://drive.google.com/drive/folders/1vqfVXhJXJWuiiXbUa4rZjOgQoJvwZUoT)
|
51 |
+
- **Paper:** [Paper](https://arxiv.org/pdf/2005.00660.pdf)
|
52 |
+
- **Point of Contact:**[Sumithra Bhakthavatsalam]([email protected])
|
53 |
+
[Chloe Anastasiades]([email protected])
|
54 |
+
[Peter Clark]([email protected])
|
55 |
+
Alternatively email_at [email protected]
|
56 |
+
|
57 |
+
|
58 |
+
### Dataset Summary
|
59 |
+
|
60 |
+
Dataset contains a large (3.5M+ sentence) knowledge base of *generic sentences*. This is the first large resource to contain *naturally occurring* generic sentences, rich in high-quality, general, semantically complete statements. All GenericsKB sentences are annotated with their topical term, surrounding context (sentences), and a (learned) confidence. We also release GenericsKB-Best (1M+ sentences), containing the best-quality generics in GenericsKB augmented with selected, synthesized generics from WordNet and ConceptNet. This demonstrates that GenericsKB can be a useful resource for NLP applications, as well as providing data for linguistic studies of generics and their semantics.
|
61 |
+
|
62 |
+
### Supported Tasks and Leaderboards
|
63 |
+
|
64 |
+
[More Information Needed]
|
65 |
+
|
66 |
+
### Languages
|
67 |
+
|
68 |
+
The dataset is in English.
|
69 |
+
|
70 |
+
## Dataset Structure
|
71 |
+
|
72 |
+
### Data Instances
|
73 |
+
|
74 |
+
The GENERICSKB contains 3,433,000 sentences. GENERICS-KB-BEST comprises of GENERICSKB generics with a score > 0.234, augmented with short generics synthesized from three other resources for all the terms (generic categories) in GENERICSKB- BEST. GENERICSKB-BEST contains 1,020,868 generics (774,621 from GENERICSKB plus 246,247 synthesized).
|
75 |
+
SimpleWikipedia is a filtered scrape of SimpleWikipedia pages (simple.wikipedia.org). The Waterloo corpus is 280GB of English plain text, gathered by Charles Clarke (Univ. Waterloo) using a webcrawler in 2001 from .edu domains.
|
76 |
+
|
77 |
+
###### Sample SimpleWikipedia/ Waterloo config look like this
|
78 |
+
```
|
79 |
+
{'source_name': 'SimpleWikipedia', 'sentence': 'Sepsis happens when the bacterium enters the blood and make it form tiny clots.', 'sentences_before': [], 'sentences_after': [], 'concept_name': 'sepsis', 'quantifiers': {}, 'id': 'SimpleWikipedia--tmp-sw-rs1-with-bug-fixes-initialprocessing-inputs-articles-with-clean-sentences-jsonl-c27816b298e1e0b5326916ee4e2fd0f1603caa77-100-Bubonic-plague--Different-kinds-of-the-same-disease--Septicemic-plague-0-0-039fbe9c11adde4ff9a829376ca7e0ed-1560874903-47882-/Users/chloea/Documents/aristo/commonsense/kbs/simplewikipedia/commonsense-filtered-good-rs1.jsonl-1f33b1e84018a2b1bfdf446f9a6491568b5585da-1561086091.8220549', 'bert_score': 0.8396177887916565}
|
80 |
+
```
|
81 |
+
###### Sample instance for Generics KB datasets look like this:
|
82 |
+
```
|
83 |
+
{'source': 'Waterloo', 'term': 'aardvark', 'quantifier_frequency': '', 'quantifier_number': '', 'generic_sentence': 'Aardvarks are very gentle animals.', 'score': '0.36080607771873474'}
|
84 |
+
{'source': 'TupleKB', 'term': 'aardvark', 'quantifier_frequency': '', 'quantifier_number': '', 'generic_sentence': 'Aardvarks dig burrows.', 'score': '1.0'}
|
85 |
+
```
|
86 |
+
### Data Fields
|
87 |
+
|
88 |
+
The fields in GenericsKB-Best.tsv and GenericsKB.tsv are as follows:
|
89 |
+
- `SOURCE`: denotes the source of the generic
|
90 |
+
- `TERM`: denotes the category that is the topic of the generic.
|
91 |
+
- `GENERIC SENTENCE`: is the sentence itself.
|
92 |
+
- `SCORE`: Is the BERT-trained score, measuring the degree to which the generic represents a "useful, general truth" about the world (as judged by crowdworkers). Score ranges from 0 (worst) to 1 (best). Sentences with scores below 0.23 (corresponding to an "unsure" vote by crowdworkers) are in GenericsKB, but are not part of GenericsKB-Best due to their unreliability.
|
93 |
+
- `QUANTIFIER_FREQUENCY`:For generics with explicit quantifiers (all, most, etc.) the quantifier is listed - Frequency contains values such as 'usually', 'often', 'frequently'
|
94 |
+
- `QUANTIFIER_NUMBER`: For generics with explicit quantifiers (all, most, etc.) with values such as 'all'|'any'|'most'|'much'|'some' etc...
|
95 |
+
|
96 |
+
The SimpleWiki/Waterloo 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.
|
97 |
+
There is a json representation for every generic statement in the Generics KB. The generic statement is stored under the `sentence` field within the `knowledge` object. There is also a `bert_score` associated with each sentence which is the BERT-based classifier's score for the 'genericness' of the statement. This score is meant to reflect how much generalized world knowledge/commonsense the statement captures vs only being contextually meaningful.
|
98 |
+
Detailed description of each of the fields:
|
99 |
+
|
100 |
+
- `source_name`: The name of the corpus the generic statement was picked from.
|
101 |
+
- `sentence`: The generic sentence.
|
102 |
+
- `sentences_before`: Provides context information surrounding the generic statement from the original corpus.Up to five sentences preceding the generic sentence in the original corpus.
|
103 |
+
- `sentences_after`: Up to five sentences following the generic sentence in the original corpus.
|
104 |
+
- `concept_name`: A concept that is the subject of the generic statement.
|
105 |
+
- `quantifiers`: The quantifiers for the key concept of the generic statement. There can be multiple quantifiers to allow for statements such as "All bats sometimes fly", where 'all' and 'sometimes' are both quantifiers reflecting number and frequency respectively.
|
106 |
+
- `id`: Unique identifier for a generic statement in the kb.
|
107 |
+
- `bert_score`: Score for the generic statement from the BERT-based generics classifier.
|
108 |
+
<br>**Additional fields that apply only to SimpleWiki dataset**
|
109 |
+
- `headings`: A breadcrumb of section/subsection headings from the top down to the location of the generic statement in the corpus. It applies to SimpleWikipedia which has a hierarchical structure.
|
110 |
+
- `categories`:The listed categories under which the source article falls. Applies to SimpleWikipedia.
|
111 |
+
|
112 |
+
|
113 |
+
### Data Splits
|
114 |
+
|
115 |
+
There are no splits.
|
116 |
+
|
117 |
+
## Dataset Creation
|
118 |
+
|
119 |
+
### Curation Rationale
|
120 |
+
|
121 |
+
[More Information Needed]
|
122 |
+
|
123 |
+
### Source Data
|
124 |
+
|
125 |
+
#### Initial Data Collection and Normalization
|
126 |
+
|
127 |
+
Data was crawled. SimpleWikipedia is a filtered scrape of SimpleWikipedia pages (simple.wikipedia.org). The Waterloo corpus is 280GB of English plain text, gathered by Charles Clarke (Univ. Waterloo) using a webcrawler in 2001 from .edu domains.
|
128 |
+
|
129 |
+
#### Who are the source language producers?
|
130 |
+
|
131 |
+
[More Information Needed]
|
132 |
+
|
133 |
+
### Annotations
|
134 |
+
|
135 |
+
#### Annotation process
|
136 |
+
|
137 |
+
Bert was used to decide whether the sentence is useful or not. Every sentence has a bert score.
|
138 |
+
|
139 |
+
#### Who are the annotators?
|
140 |
+
|
141 |
+
No annotations were made.
|
142 |
+
|
143 |
+
### Personal and Sensitive Information
|
144 |
+
|
145 |
+
[More Information Needed]
|
146 |
+
|
147 |
+
## Considerations for Using the Data
|
148 |
+
|
149 |
+
### Social Impact of Dataset
|
150 |
+
|
151 |
+
[More Information Needed]
|
152 |
+
|
153 |
+
### Discussion of Biases
|
154 |
+
|
155 |
+
[More Information Needed]
|
156 |
+
|
157 |
+
### Other Known Limitations
|
158 |
+
|
159 |
+
[More Information Needed]
|
160 |
+
|
161 |
+
## Additional Information
|
162 |
+
|
163 |
+
### Dataset Curators
|
164 |
+
|
165 |
+
[More Information Needed]
|
166 |
+
|
167 |
+
### Licensing Information
|
168 |
+
|
169 |
+
The GenericsKB is available under the Creative Commons - Attribution 4.0 International - licence.
|
170 |
+
|
171 |
+
As an informal summary, from https://creativecommons.org/licenses/by/4.0/, you are free to:
|
172 |
+
|
173 |
+
Share ― copy and redistribute the material in any medium or format
|
174 |
+
Adapt ― remix, transform, and build upon the material for any purpose, even commercially.
|
175 |
+
|
176 |
+
under the following terms:
|
177 |
+
|
178 |
+
Attribution ― You must give appropriate credit, provide a link to the license, and
|
179 |
+
indicate if changes were made. You may do so in any reasonable manner,
|
180 |
+
but not in any way that suggests the licensor endorses you or your use.
|
181 |
+
No additional restrictions ― You may not apply legal terms or technological measures
|
182 |
+
that legally restrict others from doing anything the license permits.
|
183 |
+
|
184 |
+
For details, see https://creativecommons.org/licenses/by/4.0/ or the or the included
|
185 |
+
file "Creative Commons ― Attribution 4.0 International ― CC BY 4.0.pdf" in this folder.
|
186 |
+
|
187 |
+
### Citation Information
|
188 |
+
```
|
189 |
+
@InProceedings{huggingface:dataset,
|
190 |
+
title = {GenericsKB: A Knowledge Base of Generic Statements},
|
191 |
+
authors={Sumithra Bhakthavatsalam, Chloe Anastasiades, Peter Clark},
|
192 |
+
year={2020},
|
193 |
+
publisher = {Allen Institute for AI},
|
194 |
+
}
|
195 |
+
```
|
dataset_infos.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
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}}
|
dummy/generics_kb/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7b32717594e3df07c6365c073c3cbce34da9af451e3ac9e0ece22ea171d94561
|
3 |
+
size 624
|
dummy/generics_kb_best/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:155593c88d4746c25fb1811988749c236a4a1924a59d90254130bda6b21b1d06
|
3 |
+
size 638
|
dummy/generics_kb_simplewiki/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b1ea088a2c4e3b97d30db11cb0a48efaf6d0ad8ce48ef1b96d78d71c3148d97c
|
3 |
+
size 1828
|
dummy/generics_kb_waterloo/1.0.0/dummy_data.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:665e5b672592d4dfa1185ebeb727d80b94707a228ffaa7e1d88a9cc34b3956c7
|
3 |
+
size 1320
|
generics_kb.py
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
|
3 |
+
#
|
4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
+
# you may not use this file except in compliance with the License.
|
6 |
+
# You may obtain a copy of the License at
|
7 |
+
#
|
8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9 |
+
#
|
10 |
+
# Unless required by applicable law or agreed to in writing, software
|
11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
+
# See the License for the specific language governing permissions and
|
14 |
+
# limitations under the License.
|
15 |
+
"""Generics KB: A Knowledge Base of Generic Statements"""
|
16 |
+
|
17 |
+
from __future__ import absolute_import, division, print_function
|
18 |
+
|
19 |
+
import ast
|
20 |
+
import csv
|
21 |
+
import os
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
|
25 |
+
|
26 |
+
# TODO: Add BibTeX citation
|
27 |
+
# Find for instance the citation on arxiv or on the dataset repo/website
|
28 |
+
_CITATION = """\
|
29 |
+
@InProceedings{huggingface:dataset,
|
30 |
+
title = {GenericsKB: A Knowledge Base of Generic Statements},
|
31 |
+
authors={Sumithra Bhakthavatsalam, Chloe Anastasiades, Peter Clark},
|
32 |
+
year={2020},
|
33 |
+
publisher = {Allen Institute for AI},
|
34 |
+
}
|
35 |
+
"""
|
36 |
+
|
37 |
+
_DESCRIPTION = """\
|
38 |
+
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.
|
39 |
+
"""
|
40 |
+
|
41 |
+
_HOMEPAGE = "https://allenai.org/data/genericskb"
|
42 |
+
|
43 |
+
_LICENSE = "cc-by-4.0"
|
44 |
+
|
45 |
+
_URL = "https://drive.google.com/u/0/uc?id={0}&export=download"
|
46 |
+
|
47 |
+
_FILEPATHS = {
|
48 |
+
"generics_kb_best": _URL.format("12DfIzoWyHIQqssgUgDvz3VG8_ScSh6ng"),
|
49 |
+
"generics_kb": _URL.format("1UOIEzQTid7SzKx2tbwSSPxl7g-CjpoZa"),
|
50 |
+
"generics_kb_simplewiki": _URL.format("1SpN9Qc7XRy5xs4tIfXkcLOEAP2IVaK15"),
|
51 |
+
"generics_kb_waterloo": "cskb-waterloo-06-21-with-bert-scores.jsonl",
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
class GenericsKb(datasets.GeneratorBasedBuilder):
|
56 |
+
""" The GenericsKB is the first large-scale resource containing naturally occurring generic sentences, and is rich in high-quality, general, semantically complete statements."""
|
57 |
+
|
58 |
+
VERSION = datasets.Version("1.0.0")
|
59 |
+
|
60 |
+
BUILDER_CONFIGS = [
|
61 |
+
datasets.BuilderConfig(
|
62 |
+
name="generics_kb_best",
|
63 |
+
version=VERSION,
|
64 |
+
description="This is the default and recommended config.Comprises of GENERICSKB generics with a score > 0.234 ",
|
65 |
+
),
|
66 |
+
datasets.BuilderConfig(
|
67 |
+
name="generics_kb", version=VERSION, description="This GENERICSKB that contains 3,433,000 sentences."
|
68 |
+
),
|
69 |
+
datasets.BuilderConfig(
|
70 |
+
name="generics_kb_simplewiki",
|
71 |
+
version=VERSION,
|
72 |
+
description="SimpleWikipedia is a filtered scrape of SimpleWikipedia pages (simple.wikipedia.org)",
|
73 |
+
),
|
74 |
+
datasets.BuilderConfig(
|
75 |
+
name="generics_kb_waterloo",
|
76 |
+
version=VERSION,
|
77 |
+
description="The Waterloo corpus is 280GB of English plain text, gathered by Charles Clarke (Univ. Waterloo) using a webcrawler in 2001 from .edu domains.",
|
78 |
+
),
|
79 |
+
]
|
80 |
+
|
81 |
+
@property
|
82 |
+
def manual_download_instructions(self):
|
83 |
+
return """\
|
84 |
+
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.
|
85 |
+
The <path/to/folder> can e.g. be `~/Downloads/GenericsKB`. Download the following required files from https://drive.google.com/drive/folders/1vqfVXhJXJWuiiXbUa4rZjOgQoJvwZUoT
|
86 |
+
For working on "generics_kb_waterloo" data,
|
87 |
+
1. Manually download 'GenericsKB-Waterloo-WithContext.jsonl.zip' into your <path/to/folder>.Please ensure the filename is as is.
|
88 |
+
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.
|
89 |
+
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.
|
90 |
+
Ensure you move this file into your <path/to/folder>.
|
91 |
+
|
92 |
+
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.
|
93 |
+
1. `datasets.load_dataset("generics_kb","generics_kb_best")`.
|
94 |
+
2. `datasets.load_dataset("generics_kb","generics_kb")`
|
95 |
+
3. `datasets.load_dataset("generics_kb","generics_kb_simplewiki")`
|
96 |
+
4. `datasets.load_dataset("generics_kb","generics_kb_waterloo", data_dir="<path/to/folder>")`
|
97 |
+
|
98 |
+
"""
|
99 |
+
|
100 |
+
DEFAULT_CONFIG_NAME = "generics_kb_best"
|
101 |
+
|
102 |
+
def _info(self):
|
103 |
+
if self.config.name == "generics_kb_waterloo" or self.config.name == "generics_kb_simplewiki":
|
104 |
+
|
105 |
+
featuredict = {
|
106 |
+
"source_name": datasets.Value("string"),
|
107 |
+
"sentence": datasets.Value("string"),
|
108 |
+
"sentences_before": datasets.Sequence(datasets.Value("string")),
|
109 |
+
"sentences_after": datasets.Sequence(datasets.Value("string")),
|
110 |
+
"concept_name": datasets.Value("string"),
|
111 |
+
"quantifiers": datasets.Sequence(datasets.Value("string")),
|
112 |
+
"id": datasets.Value("string"),
|
113 |
+
"bert_score": datasets.Value("float64"),
|
114 |
+
}
|
115 |
+
if self.config.name == "generics_kb_simplewiki":
|
116 |
+
featuredict["headings"] = datasets.Sequence(datasets.Value("string"))
|
117 |
+
featuredict["categories"] = datasets.Sequence(datasets.Value("string"))
|
118 |
+
|
119 |
+
features = datasets.Features(featuredict)
|
120 |
+
|
121 |
+
else:
|
122 |
+
|
123 |
+
features = datasets.Features(
|
124 |
+
{
|
125 |
+
"source": datasets.Value("string"),
|
126 |
+
"term": datasets.Value("string"),
|
127 |
+
"quantifier_frequency": datasets.Value("string"),
|
128 |
+
"quantifier_number": datasets.Value("string"),
|
129 |
+
"generic_sentence": datasets.Value("string"),
|
130 |
+
"score": datasets.Value("float64"),
|
131 |
+
}
|
132 |
+
)
|
133 |
+
|
134 |
+
return datasets.DatasetInfo(
|
135 |
+
# This is the description that will appear on the datasets page.
|
136 |
+
description=_DESCRIPTION,
|
137 |
+
# This defines the different columns of the dataset and their types
|
138 |
+
features=features, # Here we define them above because they are different between the two configurations
|
139 |
+
# If there's a common (input, target) tuple from the features,
|
140 |
+
# specify them here. They'll be used if as_supervised=True in
|
141 |
+
# builder.as_dataset.
|
142 |
+
supervised_keys=None,
|
143 |
+
# Homepage of the dataset for documentation
|
144 |
+
homepage=_HOMEPAGE,
|
145 |
+
# License for the dataset if available
|
146 |
+
license=_LICENSE,
|
147 |
+
# Citation for the dataset
|
148 |
+
citation=_CITATION,
|
149 |
+
)
|
150 |
+
|
151 |
+
def _split_generators(self, dl_manager):
|
152 |
+
|
153 |
+
if self.config.name == "generics_kb_waterloo":
|
154 |
+
data_dir = os.path.abspath(os.path.expanduser(dl_manager.manual_dir))
|
155 |
+
# check if manual folder exists
|
156 |
+
if not os.path.exists(data_dir):
|
157 |
+
raise FileNotFoundError(
|
158 |
+
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})"
|
159 |
+
)
|
160 |
+
|
161 |
+
# Check if required files exist in the folder
|
162 |
+
filepath = os.path.join(data_dir, _FILEPATHS[self.config.name])
|
163 |
+
|
164 |
+
if not os.path.exists(filepath):
|
165 |
+
raise FileNotFoundError(
|
166 |
+
f"{filepath} does not exist. Make sure you required files are present in {data_dir} `. Manual download instructions: {self.manual_download_instructions})"
|
167 |
+
)
|
168 |
+
else:
|
169 |
+
filepath = dl_manager.download(_FILEPATHS[self.config.name])
|
170 |
+
|
171 |
+
return [
|
172 |
+
datasets.SplitGenerator(
|
173 |
+
name=datasets.Split.TRAIN,
|
174 |
+
# These kwargs will be passed to _generate_examples
|
175 |
+
gen_kwargs={
|
176 |
+
"filepath": filepath,
|
177 |
+
},
|
178 |
+
),
|
179 |
+
]
|
180 |
+
|
181 |
+
def _generate_examples(self, filepath):
|
182 |
+
""" Yields examples. """
|
183 |
+
|
184 |
+
if self.config.name == "generics_kb_waterloo" or self.config.name == "generics_kb_simplewiki":
|
185 |
+
|
186 |
+
with open(filepath, encoding="utf-8") as f:
|
187 |
+
for id_, row in enumerate(f):
|
188 |
+
data = ast.literal_eval(row)
|
189 |
+
|
190 |
+
result = {
|
191 |
+
"source_name": data["source"]["name"],
|
192 |
+
"sentence": data["knowledge"]["sentence"],
|
193 |
+
"sentences_before": data["knowledge"]["context"]["sentences_before"],
|
194 |
+
"sentences_after": data["knowledge"]["context"]["sentences_after"],
|
195 |
+
"concept_name": data["knowledge"]["key_concepts"][0]["concept_name"],
|
196 |
+
"quantifiers": data["knowledge"]["key_concepts"][0]["quantifiers"],
|
197 |
+
"id": data["id"],
|
198 |
+
"bert_score": data["bert_score"],
|
199 |
+
}
|
200 |
+
if self.config.name == "generics_kb_simplewiki":
|
201 |
+
result["headings"] = data["knowledge"]["context"]["headings"]
|
202 |
+
result["categories"] = data["knowledge"]["context"]["categories"]
|
203 |
+
|
204 |
+
yield id_, result
|
205 |
+
else:
|
206 |
+
|
207 |
+
with open(filepath, encoding="utf-8") as f:
|
208 |
+
# Skip the header
|
209 |
+
next(f)
|
210 |
+
|
211 |
+
read_tsv = csv.reader(f, delimiter="\t")
|
212 |
+
|
213 |
+
for id_, row in enumerate(read_tsv):
|
214 |
+
|
215 |
+
quantifier = row[2]
|
216 |
+
quantifier_frequency = ""
|
217 |
+
quantifier_number = ""
|
218 |
+
|
219 |
+
if quantifier != "":
|
220 |
+
quantifier = ast.literal_eval(quantifier)
|
221 |
+
if "frequency" in quantifier.keys():
|
222 |
+
quantifier_frequency = quantifier["frequency"]
|
223 |
+
if "number" in quantifier.keys():
|
224 |
+
quantifier_number = quantifier["number"]
|
225 |
+
yield id_, {
|
226 |
+
"source": row[0],
|
227 |
+
"term": row[1],
|
228 |
+
"quantifier_frequency": quantifier_frequency,
|
229 |
+
"quantifier_number": quantifier_number,
|
230 |
+
"generic_sentence": row[3],
|
231 |
+
"score": row[4],
|
232 |
+
}
|