From d2d27eda4426f280a0b9abd12f5d3422a9cb94b8 Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 6 Aug 2024 13:28:45 +0530 Subject: [PATCH] Fixed an issue where some of the performances were not loading --- sparql/add_derived_from.sparql | 16 ++++++++++++++++ src/main.rb | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 sparql/add_derived_from.sparql diff --git a/sparql/add_derived_from.sparql b/sparql/add_derived_from.sparql new file mode 100644 index 0000000..34585f1 --- /dev/null +++ b/sparql/add_derived_from.sparql @@ -0,0 +1,16 @@ +PREFIX schema: +PREFIX prov: + +INSERT { + ?top_node prov:wasDerivedFrom . +} +WHERE { + { + SELECT DISTINCT ?top_node + WHERE { + ?top_node ?any_p ?any_o . + FILTER NOT EXISTS { ?other_s ?other_p ?top_node } + } + } + ?top_node ?p ?o +} diff --git a/src/main.rb b/src/main.rb index ae0243e..6f02b77 100644 --- a/src/main.rb +++ b/src/main.rb @@ -32,15 +32,18 @@ def get_entities(entityType) urls << entity['href'] end end + add_url_sparql_file = File.read('./sparql/add_derived_from.sparql') graph = RDF::Graph.new urls.each do |entity_url| begin entity_url = entity_url.gsub(' ', '+') loaded_graph = RDF::Graph.load(entity_url) + sparql_file_with_url = add_url_sparql_file.gsub("subject_url", entity_url) + loaded_graph.query(SPARQL.parse(sparql_file_with_url, update: true)) graph << loaded_graph rescue StandardError => e puts "Error loading RDF from #{entity_url}: #{e.message}" - break + next end end