Datasets:
add triples function to transform features back to RDF nodes
Browse files- yago45en.py +12 -0
yago45en.py
CHANGED
@@ -55,3 +55,15 @@ class YAGO45DatasetBuilder(GeneratorBasedBuilder):
|
|
55 |
'object': o.n3()
|
56 |
}
|
57 |
id_ += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
'object': o.n3()
|
56 |
}
|
57 |
id_ += 1
|
58 |
+
|
59 |
+
from rdflib.util import from_n3
|
60 |
+
|
61 |
+
def triples(features):
|
62 |
+
try:
|
63 |
+
subject_node = from_n3(features['subject'])
|
64 |
+
predicate_node = from_n3(features['predicate'])
|
65 |
+
object_node = from_n3(features['object'])
|
66 |
+
return (subject_node, predicate_node, object_node)
|
67 |
+
except Exception as e:
|
68 |
+
print(f"Error transforming features {features}: {e}")
|
69 |
+
return (None, None, None)
|