Skip to content
Snippets Groups Projects
Commit 9ee2e5d1 authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Add "transform" stage that constructs graph inferences

parent 4957359c
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
import export
import extract
import transform
def main():
extract.main()
# transform.main()
transform.main()
export.main()
......
from rdflib import Graph
from common import *
def construct(g: Graph, query: str):
"""Performs a SPARQL `CONSTRUCT` query and add the resulting triples
to the graph, in-place.
"""
res = g.query(query)
if res.graph is not None:
g += res.graph
def main():
# Load graph
graph = Graph()
graph.bind("", NS)
graph.parse(RDF_SCHEMA_FILE)
graph.parse(RDF_CONTENT_FILE)
construct(
graph,
"""
CONSTRUCT {
?exo a :ExerciceQC
} WHERE {
{
?exo a :ExerciceQC_QCU
} UNION {
?exo a :ExerciceQC_QCM
}
}""",
)
graph.serialize(RDF_FULL_FILE, "turtle", base=NS)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment