docfreemo commited on
Commit
31b5625
Β·
verified Β·
1 Parent(s): c863582

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +269 -25
README.md CHANGED
@@ -1,27 +1,271 @@
1
  ---
2
- dataset_info:
3
- features:
4
- - name: subject
5
- dtype: string
6
- - name: predicate
7
- dtype: string
8
- - name: object
9
- dtype: string
10
- - name: object_type
11
- dtype: string
12
- - name: object_datatype
13
- dtype: string
14
- - name: object_language
15
- dtype: string
16
- splits:
17
- - name: data
18
- num_bytes: 3634248983
19
- num_examples: 22791171
20
- download_size: 706702553
21
- dataset_size: 3634248983
22
- configs:
23
- - config_name: default
24
- data_files:
25
- - split: data
26
- path: data/data-*
27
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: cc-by-sa-3.0
3
+ task_categories:
4
+ - text-generation
5
+ - feature-extraction
6
+ language:
7
+ - en
8
+ tags:
9
+ - rdf
10
+ - knowledge-graph
11
+ - semantic-web
12
+ - triples
13
+ size_categories:
14
+ - 10K<n<100K
 
 
 
 
 
 
 
 
 
 
 
 
15
  ---
16
+
17
+ # DBpedia Core (English)
18
+
19
+ ## Dataset Description
20
+
21
+ Core facts from Wikipedia (English)
22
+
23
+ **Original Source:** https://downloads.dbpedia.org/repo/dbpedia/mappings/mappingbased-objects/2022.12.01/mappingbased-objects_lang=en.ttl.bz2
24
+
25
+ ### Dataset Summary
26
+
27
+ This dataset contains RDF triples from DBpedia Core (English) converted to HuggingFace dataset format
28
+ for easy use in machine learning pipelines.
29
+
30
+ - **Format:** Originally turtle, converted to HuggingFace Dataset
31
+ - **Size:** 1.8 GB (extracted)
32
+ - **Entities:** ~9.5M
33
+ - **Triples:** ~50-60M
34
+ - **Original License:** CC BY-SA 3.0
35
+
36
+ ### Recommended Use
37
+
38
+ Wikipedia-based knowledge, production training
39
+
40
+ ### Notes\n\nCore DBpedia facts extracted from Wikipedia infoboxes
41
+
42
+
43
+ ## Dataset Format: Lossless RDF Representation
44
+
45
+ This dataset uses a **standard lossless format** for representing RDF (Resource Description Framework)
46
+ data in HuggingFace Datasets. All semantic information from the original RDF knowledge graph is preserved,
47
+ enabling perfect round-trip conversion between RDF and HuggingFace formats.
48
+
49
+ ### Schema
50
+
51
+ Each RDF triple is represented as a row with **6 fields**:
52
+
53
+ | Field | Type | Description | Example |
54
+ |-------|------|-------------|---------|
55
+ | `subject` | string | Subject of the triple (URI or blank node) | `"http://schema.org/Person"` |
56
+ | `predicate` | string | Predicate URI | `"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"` |
57
+ | `object` | string | Object of the triple | `"John Doe"` or `"http://schema.org/Thing"` |
58
+ | `object_type` | string | Type of object: `"uri"`, `"literal"`, or `"blank_node"` | `"literal"` |
59
+ | `object_datatype` | string | XSD datatype URI (for typed literals) | `"http://www.w3.org/2001/XMLSchema#integer"` |
60
+ | `object_language` | string | Language tag (for language-tagged literals) | `"en"` |
61
+
62
+ ### Example: RDF Triple Representation
63
+
64
+ **Original RDF (Turtle)**:
65
+ ```turtle
66
+ <http://example.org/John> <http://schema.org/name> "John Doe"@en .
67
+ ```
68
+
69
+ **HuggingFace Dataset Row**:
70
+ ```python
71
+ {
72
+ "subject": "http://example.org/John",
73
+ "predicate": "http://schema.org/name",
74
+ "object": "John Doe",
75
+ "object_type": "literal",
76
+ "object_datatype": None,
77
+ "object_language": "en"
78
+ }
79
+ ```
80
+
81
+ ### Loading the Dataset
82
+
83
+ ```python
84
+ from datasets import load_dataset
85
+
86
+ # Load the dataset
87
+ dataset = load_dataset("CleverThis/dbpedia-core-en")
88
+
89
+ # Access the data
90
+ data = dataset["data"]
91
+
92
+ # Iterate over triples
93
+ for row in data:
94
+ subject = row["subject"]
95
+ predicate = row["predicate"]
96
+ obj = row["object"]
97
+ obj_type = row["object_type"]
98
+
99
+ print(f"Triple: ({subject}, {predicate}, {obj})")
100
+ print(f" Object type: {obj_type}")
101
+ if row["object_language"]:
102
+ print(f" Language: {row['object_language']}")
103
+ if row["object_datatype"]:
104
+ print(f" Datatype: {row['object_datatype']}")
105
+ ```
106
+
107
+ ### Converting Back to RDF
108
+
109
+ The dataset can be converted back to any RDF format (Turtle, N-Triples, RDF/XML, etc.) with **zero information loss**:
110
+
111
+ ```python
112
+ from datasets import load_dataset
113
+ from rdflib import Graph, URIRef, Literal, BNode
114
+
115
+ def convert_to_rdf(dataset_name, output_file="output.ttl", split="data"):
116
+ """Convert HuggingFace dataset back to RDF Turtle format."""
117
+ # Load dataset
118
+ dataset = load_dataset(dataset_name)
119
+
120
+ # Create RDF graph
121
+ graph = Graph()
122
+
123
+ # Convert each row to RDF triple
124
+ for row in dataset[split]:
125
+ # Subject
126
+ if row["subject"].startswith("_:"):
127
+ subject = BNode(row["subject"][2:])
128
+ else:
129
+ subject = URIRef(row["subject"])
130
+
131
+ # Predicate (always URI)
132
+ predicate = URIRef(row["predicate"])
133
+
134
+ # Object (depends on object_type)
135
+ if row["object_type"] == "uri":
136
+ obj = URIRef(row["object"])
137
+ elif row["object_type"] == "blank_node":
138
+ obj = BNode(row["object"][2:])
139
+ elif row["object_type"] == "literal":
140
+ if row["object_datatype"]:
141
+ obj = Literal(row["object"], datatype=URIRef(row["object_datatype"]))
142
+ elif row["object_language"]:
143
+ obj = Literal(row["object"], lang=row["object_language"])
144
+ else:
145
+ obj = Literal(row["object"])
146
+
147
+ graph.add((subject, predicate, obj))
148
+
149
+ # Serialize to Turtle (or any RDF format)
150
+ graph.serialize(output_file, format="turtle")
151
+ print(f"Exported {len(graph)} triples to {output_file}")
152
+ return graph
153
+
154
+ # Usage
155
+ graph = convert_to_rdf("CleverThis/dbpedia-core-en", "reconstructed.ttl")
156
+ ```
157
+
158
+ ### Information Preservation Guarantee
159
+
160
+ This format preserves **100% of RDF information**:
161
+
162
+ - βœ… **URIs**: Exact string representation preserved
163
+ - βœ… **Literals**: Full text content preserved
164
+ - βœ… **Datatypes**: XSD and custom datatypes preserved (e.g., `xsd:integer`, `xsd:dateTime`)
165
+ - βœ… **Language Tags**: BCP 47 language tags preserved (e.g., `@en`, `@fr`, `@ja`)
166
+ - βœ… **Blank Nodes**: Node structure preserved (identifiers may change but graph isomorphism maintained)
167
+
168
+ **Round-trip guarantee**: Original RDF β†’ HuggingFace β†’ Reconstructed RDF produces **semantically identical** graphs.
169
+
170
+ ### Querying the Dataset
171
+
172
+ You can filter and query the dataset like any HuggingFace dataset:
173
+
174
+ ```python
175
+ from datasets import load_dataset
176
+
177
+ dataset = load_dataset("CleverThis/dbpedia-core-en")
178
+
179
+ # Find all triples with English literals
180
+ english_literals = dataset["data"].filter(
181
+ lambda x: x["object_type"] == "literal" and x["object_language"] == "en"
182
+ )
183
+ print(f"Found {len(english_literals)} English literals")
184
+
185
+ # Find all rdf:type statements
186
+ type_statements = dataset["data"].filter(
187
+ lambda x: "rdf-syntax-ns#type" in x["predicate"]
188
+ )
189
+ print(f"Found {len(type_statements)} type statements")
190
+
191
+ # Convert to Pandas for analysis
192
+ import pandas as pd
193
+ df = dataset["data"].to_pandas()
194
+
195
+ # Analyze predicate distribution
196
+ print(df["predicate"].value_counts())
197
+ ```
198
+
199
+ ### Dataset Format
200
+
201
+ The dataset contains all triples in a single **data** split, suitable for machine learning tasks such as:
202
+
203
+ - Knowledge graph completion
204
+ - Link prediction
205
+ - Entity embedding
206
+ - Relation extraction
207
+ - Graph neural networks
208
+
209
+ ### Format Specification
210
+
211
+ For complete technical documentation of the RDF-to-HuggingFace format, see:
212
+
213
+ πŸ“– [RDF to HuggingFace Format Specification](https://github.com/CleverThis/cleverernie/blob/master/docs/rdf_huggingface_format_specification.md)
214
+
215
+ The specification includes:
216
+ - Detailed schema definition
217
+ - All RDF node type mappings
218
+ - Performance benchmarks
219
+ - Edge cases and limitations
220
+ - Complete code examples
221
+
222
+ ### Conversion Metadata
223
+
224
+ - **Source Format**: turtle
225
+ - **Original Size**: 1.8 GB
226
+ - **Conversion Tool**: [CleverErnie RDF Pipeline](https://github.com/CleverThis/cleverernie)
227
+ - **Format Version**: 1.0
228
+ - **Conversion Date**: 2025-11-18
229
+
230
+
231
+ ## Citation
232
+
233
+ If you use this dataset, please cite the original source:
234
+
235
+ **Original Dataset:** DBpedia Core (English)
236
+ **URL:** https://downloads.dbpedia.org/repo/dbpedia/mappings/mappingbased-objects/2022.12.01/mappingbased-objects_lang=en.ttl.bz2
237
+ **License:** CC BY-SA 3.0
238
+
239
+ ## Dataset Preparation
240
+
241
+ This dataset was prepared using the CleverErnie GISM framework:
242
+
243
+ ```bash
244
+ # Download original dataset
245
+ python scripts/rdf_dataset_downloader.py dbpedia-core-en -o datasets/
246
+
247
+ # Convert to HuggingFace format
248
+ python scripts/convert_rdf_to_hf_dataset.py \
249
+ datasets/dbpedia-core-en/[file] \
250
+ hf_datasets/dbpedia-core-en \
251
+ --format turtle
252
+
253
+ # Upload to HuggingFace Hub
254
+ python scripts/upload_all_datasets.py --dataset dbpedia-core-en
255
+ ```
256
+
257
+ ## Additional Information
258
+
259
+ ### Original Source
260
+
261
+ https://downloads.dbpedia.org/repo/dbpedia/mappings/mappingbased-objects/2022.12.01/mappingbased-objects_lang=en.ttl.bz2
262
+
263
+ ### Conversion Details
264
+
265
+ - Converted using: [CleverErnie GISM](https://github.com/cleverthis/cleverernie)
266
+ - Conversion script: `scripts/convert_rdf_to_hf_dataset.py`
267
+ - Dataset format: Single 'data' split with all triples
268
+
269
+ ### Maintenance
270
+
271
+ This dataset is maintained by the CleverThis organization.