Skip to content

Commit

Permalink
Fixed an issue where some of the performances were not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-aravind committed Aug 6, 2024
1 parent b0b7f91 commit d2d27ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions sparql/add_derived_from.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PREFIX schema: <http://schema.org/>
PREFIX prov: <http://www.w3.org/ns/prov#>

INSERT {
?top_node prov:wasDerivedFrom <subject_url> .
}
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
}
5 changes: 4 additions & 1 deletion src/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d2d27ed

Please sign in to comment.