Datasets:
update script
Browse files- .gitattributes +1 -1
- README.md +0 -12
- raw/facts.tar.gz → facts.tar.gz +0 -0
- raw/filter.sparql → filter.sparql +0 -0
- raw/yago-taxonomy.ttl → yago-taxonomy.ttl +0 -0
- yago-4.5-en.py → yago45en.py +19 -17
.gitattributes
CHANGED
|
@@ -53,4 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 56 |
-
|
|
|
|
| 53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
yago-taxonomy.ttl filter=lfs diff=lfs merge=lfs -text
|
README.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
dataset_info:
|
| 3 |
-
features:
|
| 4 |
-
- name: text
|
| 5 |
-
dtype: string
|
| 6 |
-
splits:
|
| 7 |
-
- name: train
|
| 8 |
-
num_bytes: 17
|
| 9 |
-
num_examples: 1
|
| 10 |
-
download_size: 14
|
| 11 |
-
dataset_size: 17
|
| 12 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
raw/facts.tar.gz → facts.tar.gz
RENAMED
|
File without changes
|
raw/filter.sparql → filter.sparql
RENAMED
|
File without changes
|
raw/yago-taxonomy.ttl → yago-taxonomy.ttl
RENAMED
|
File without changes
|
yago-4.5-en.py → yago45en.py
RENAMED
|
@@ -1,7 +1,8 @@
|
|
| 1 |
import os
|
| 2 |
-
from datasets import DatasetBuilder, SplitGenerator, DownloadConfig, load_dataset, DownloadManager
|
| 3 |
from rdflib import Graph, URIRef, Literal, BNode
|
| 4 |
from rdflib.namespace import RDF, RDFS, OWL, XSD, Namespace, NamespaceManager
|
|
|
|
| 5 |
|
| 6 |
SCHEMA = Namespace('http://schema.org/')
|
| 7 |
|
|
@@ -13,17 +14,18 @@ class YAGO45DatasetBuilder(DatasetBuilder):
|
|
| 13 |
taxonomy = Graph(bind_namespaces="core")
|
| 14 |
|
| 15 |
def _info(self):
|
| 16 |
-
|
| 17 |
-
return
|
| 18 |
-
"
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
def _split_generators(self, dl_manager):
|
| 29 |
# Download and extract the dataset
|
|
@@ -31,7 +33,7 @@ class YAGO45DatasetBuilder(DatasetBuilder):
|
|
| 31 |
|
| 32 |
# Download and extract the dataset files
|
| 33 |
dl_manager.download_config = DownloadConfig(cache_dir=os.path.abspath("raw"))
|
| 34 |
-
dl_manager.download_and_extract(["
|
| 35 |
|
| 36 |
# Load yago-taxonomy.ttl file in every process
|
| 37 |
self.taxonomy.parse(os.path.join(dl_manager.manual_dir, 'yago-taxonomy.ttl'), format='turtle')
|
|
@@ -53,11 +55,11 @@ class YAGO45DatasetBuilder(DatasetBuilder):
|
|
| 53 |
graph.parse(chunk_path, format='nt')
|
| 54 |
|
| 55 |
# Yield individual triples from the graph
|
| 56 |
-
for i, (
|
| 57 |
yield i, {
|
| 58 |
-
'subject': str(
|
| 59 |
-
'predicate': str(
|
| 60 |
-
'object': str(
|
| 61 |
}
|
| 62 |
|
| 63 |
|
|
|
|
| 1 |
import os
|
| 2 |
+
from datasets import DatasetBuilder, SplitGenerator, DownloadConfig, load_dataset, DownloadManager, DatasetInfo
|
| 3 |
from rdflib import Graph, URIRef, Literal, BNode
|
| 4 |
from rdflib.namespace import RDF, RDFS, OWL, XSD, Namespace, NamespaceManager
|
| 5 |
+
from datasets.features import Features, Value
|
| 6 |
|
| 7 |
SCHEMA = Namespace('http://schema.org/')
|
| 8 |
|
|
|
|
| 14 |
taxonomy = Graph(bind_namespaces="core")
|
| 15 |
|
| 16 |
def _info(self):
|
| 17 |
+
print("INFO")
|
| 18 |
+
return DatasetInfo(
|
| 19 |
+
description="A subset of the YAGO 4.5 dataset maintaining only English labels",
|
| 20 |
+
citation="@article{suchanek2023integrating,title={Integrating the Wikidata Taxonomy into YAGO},author={Suchanek, Fabian M and Alam, Mehwish and Bonald, Thomas and Paris, Pierre-Henri and Soria, Jules},journal={arXiv preprint arXiv:2308.11884},year={2023}}",
|
| 21 |
+
homepage="https://yago-knowledge.org/",
|
| 22 |
+
license="https://creativecommons.org/licenses/by-sa/3.0/",
|
| 23 |
+
features=Features({
|
| 24 |
+
'subject': Value('string'),
|
| 25 |
+
'predicate': Value('string'),
|
| 26 |
+
'object': Value('string')
|
| 27 |
+
})
|
| 28 |
+
)
|
| 29 |
|
| 30 |
def _split_generators(self, dl_manager):
|
| 31 |
# Download and extract the dataset
|
|
|
|
| 33 |
|
| 34 |
# Download and extract the dataset files
|
| 35 |
dl_manager.download_config = DownloadConfig(cache_dir=os.path.abspath("raw"))
|
| 36 |
+
dl_manager.download_and_extract(["facts.tar.gz", "yago-taxonomy.ttl"])
|
| 37 |
|
| 38 |
# Load yago-taxonomy.ttl file in every process
|
| 39 |
self.taxonomy.parse(os.path.join(dl_manager.manual_dir, 'yago-taxonomy.ttl'), format='turtle')
|
|
|
|
| 55 |
graph.parse(chunk_path, format='nt')
|
| 56 |
|
| 57 |
# Yield individual triples from the graph
|
| 58 |
+
for i, (s, p, o) in enumerate(graph):
|
| 59 |
yield i, {
|
| 60 |
+
'subject': str(s),
|
| 61 |
+
'predicate': str(p),
|
| 62 |
+
'object': str(o)
|
| 63 |
}
|
| 64 |
|
| 65 |
|