Skip to content

Commit

Permalink
added correct path to sparql
Browse files Browse the repository at this point in the history
  • Loading branch information
saumier committed May 15, 2024
1 parent 256aca8 commit a808b00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
13 changes: 5 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,13 @@ GEM
multi_json (1.15.0)
net-http-persistent (4.0.2)
connection_pool (~> 2.2)
nokogiri (1.16.2-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
nokogiri (1.16.5-x86_64-darwin)
racc (~> 1.4)
psych (5.1.2)
stringio
public_suffix (5.0.4)
public_suffix (5.0.5)
racc (1.7.3)
rack (3.0.9)
rack (3.0.11)
rdf (3.3.1)
bcp47_spec (~> 0.2)
link_header (~> 0.0, >= 0.0.8)
Expand Down Expand Up @@ -177,7 +175,7 @@ GEM
matrix (~> 0.4)
rdf (~> 3.3)
temple (0.10.3)
thor (1.3.0)
thor (1.3.1)
tilt (2.3.0)
unicode-types (1.9.0)
yaml-ld (0.0.3)
Expand All @@ -188,10 +186,9 @@ GEM

PLATFORMS
x86_64-darwin-23
x86_64-linux

DEPENDENCIES
linkeddata

BUNDLED WITH
2.3.7
2.4.20
5 changes: 4 additions & 1 deletion src/sitemap_scraping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ def perform_sparql_transformations(graph, sparql_paths)
return graph
end

puts "Checking sitemap at #{sitemap_url}"
sitemap_xml = Nokogiri::XML(URI.open(sitemap_url))
# Extract URLs that start with 'https://nac-cna.ca/en/event/'
ns = { 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9' }
entity_urls = sitemap_xml.xpath('//xmlns:url[starts-with(xmlns:loc, "https://nac-cna.ca/en/event/")]/xmlns:loc', ns).map(&:text)
puts "entity_urls: #{entity_urls}"

sparql_file = File.read('./sparql/add_derived_from.sparql')
sparql_file = File.read('./src/sparql/add_derived_from.sparql')
entity_urls.each do |entity_url|
begin
entity_url = entity_url.gsub(' ', '+')
Expand All @@ -51,3 +52,5 @@ def perform_sparql_transformations(graph, sparql_paths)
File.open(file_name, 'w') do |file|
file.puts(graph.dump(:jsonld))
end

puts "Saved JSON-LD to file #{file_name}"

0 comments on commit a808b00

Please sign in to comment.