This commit is contained in:
2026-08-08 23:36:25 -04:00
parent 64a2c87346
commit 9177c8902b
3 changed files with 82 additions and 30 deletions
+10 -4
View File
@@ -49,22 +49,28 @@ fn main() -> color_eyre::Result<()> {
let inference_engine = InferenceEngine::new(store.clone());
let graph_name = GraphName::NamedNode(NamedNode::new_unchecked(format!("file://{}", args.dataset_path.to_string_lossy())));
let mut dataset = RdfParser::from_format(RdfFormat::Turtle)
let dataset = RdfParser::from_format(RdfFormat::Turtle)
.with_default_graph(graph_name)
.for_reader(File::open(&args.dataset_path)?)
.filter_map(Result::ok)
.collect::<Dataset>();
let inferences = inference_engine.run(&dataset)?;
dataset.extend(&inferences);
let dataset_with_inferences = inference_engine.run(&dataset)?;
let raw_query = String::from_utf8(std::fs::read(&args.query_path)?)?;
let mut query = SparqlEvaluator::new()
.parse_query(&raw_query)?;
query.dataset_mut().set_default_graph_as_union();
match query.on_queryable_dataset(&dataset).execute()? {
match query.on_queryable_dataset(&dataset_with_inferences).execute()? {
QueryResults::Graph(graph) => {
let mut serializer = RdfSerializer::from_format(RdfFormat::Turtle)
.with_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#")?
.with_prefix("rdac", "http://rdaregistry.info/Elements/c/")?
.with_prefix("ldp", "http://www.w3.org/ns/ldp#")?
.with_prefix("fedora", "http://fedora.info/definitions/v4/repository#")?
.with_prefix("lrmer", "http://iflastandards.info/ns/lrm/lrmer/")?
.with_prefix("owl", "http://www.w3.org/2002/07/owl#")?
.with_base_iri("http://fedora.quill.lan/rest/")?
.for_writer(std::io::stdout());
for triple in graph.filter_map(Result::ok) {
serializer.serialize_triple(triple.as_ref())?;