From 6ec06e1bd2f16afee628173dab498edf4bb85821 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Mon, 28 Oct 2024 15:33:35 +0100 Subject: [PATCH 01/17] initial commit --- bin/lov_migrator | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 bin/lov_migrator diff --git a/bin/lov_migrator b/bin/lov_migrator new file mode 100644 index 00000000..164937d0 --- /dev/null +++ b/bin/lov_migrator @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby + +# Exit cleanly from an early interrupt +Signal.trap("INT") { exit 1 } + +require 'optparse' + +options = {} +OptionParser.new do |opts| + opts.banner = "Usage: lov_migrator [options]" + opts.on( '-a', '--all') do + options[:vocabs] = [:all] + end + opts.on('-v', '--vocabularies PREFIX1, PREFIX2', 'Comma-separated list of vocabularies to update or import') do |acronym| + ontologies_acronyms = acronym + end + + # Display the help screen, all programs are assumed to have this option. + opts.on( '-h', '--help', 'Display this screen' ) do + puts opts + exit + end +end.parse! + +raise OptionParser::MissingArgument if options[:vocabs].nil? + +def logger(text, &block) + puts ">> #{text} starting..." + time = Benchmark.realtime do + block.call + end + puts "#{text} finished in #{time} seconds" +end + +def main +end + +main \ No newline at end of file From b4af5bbebb0f33a7024d2f6c97c546accf40fea8 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 29 Oct 2024 07:35:37 +0100 Subject: [PATCH 02/17] add vocabularies fetch using sparql endpoint --- bin/lov_migrator | 107 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) mode change 100644 => 100755 bin/lov_migrator diff --git a/bin/lov_migrator b/bin/lov_migrator old mode 100644 new mode 100755 index 164937d0..60e6fc85 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -14,7 +14,9 @@ OptionParser.new do |opts| opts.on('-v', '--vocabularies PREFIX1, PREFIX2', 'Comma-separated list of vocabularies to update or import') do |acronym| ontologies_acronyms = acronym end - + opts.on('--dispatch-csv') do |csv| + options[:csv_dispatch_filename] = csv + end # Display the help screen, all programs are assumed to have this option. opts.on( '-h', '--help', 'Display this screen' ) do puts opts @@ -24,15 +26,112 @@ end.parse! raise OptionParser::MissingArgument if options[:vocabs].nil? +require 'open-uri' +require 'net/http' +require 'json' +require 'date' +require 'benchmark' + +LOV_ENDPOINT = "http://localhost:3030/lov" + + +class LOVMigrator + attr_accessor :lov_endpoint + class SparqlParser + def initialize(endpoint = LOV_ENDPOINT) + @lov_endpoint = endpoint + _last_processed_date_file = ".last_processed_date.txt" + @last_processed_date = File.exist?(_last_processed_date_file) ? Date.parse(File.read(_last_processed_date_file).strip) : nil + end + + def sparql_query(query, accept_format = 'application/sparql-results+json') + uri = URI.parse("#{@lov_endpoint}/sparql") + + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = (uri.scheme == 'https') + http.verify_mode = OpenSSL::SSL::VERIFY_NONE if uri.scheme == 'https' + + request = Net::HTTP::Post.new(uri.request_uri) + request.set_form_data('query' => query) + request['Accept'] = accept_format + + response = http.request(request) + + case response + when Net::HTTPSuccess + accept_format == 'application/sparql-results+json' ? parse_json_response(response.body) : response.body + else + raise "SPARQL query failed: #{response.code} #{response.message}" + end + end + + def latest_remote_modification_date + query = <<~SPARQL + SELECT (MAX(?modified) AS ?lastModifiedInLOVAt) + WHERE { + ?catalog a . + ?catalog ?modified + } + ORDER BY DESC(?lastModifiedInLOVAt) + SPARQL + result = sparql_query(query).first + Date.parse(result["lastModifiedInLOVAt"]["value"]) + end + + def fetch_all_vocabs + query = <<~SPARQL + PREFIX foaf: + PREFIX rdf: + PREFIX rdfs: + PREFIX dct: + + SELECT DISTINCT + (GROUP_CONCAT(DISTINCT ?_prefix; separator="\\n") AS ?prefix) + (GROUP_CONCAT(DISTINCT ?_title; separator="\\n") AS ?title) + (GROUP_CONCAT(DISTINCT ?_description; separator="\\n") AS ?description) + (GROUP_CONCAT(DISTINCT ?_keyword; separator="\\n") AS ?keyword) + (GROUP_CONCAT(DISTINCT ?_creatorName; separator="\\n") AS ?creator) + ?uri + (GROUP_CONCAT(DISTINCT ?_lastModifiedInLOVAt; separator="\\n") AS ?lastModifiedInLOVAt) + + { + ?uri a . + ?catalog a . + ?catalog foaf:primaryTopic ?uri . + + ?uri ?_prefix. + ?uri ?_title. + ?uri ?_description. + ?uri ?_keyword. + OPTIONAL { + ?uri dct:creator ?_creator . + ?_creator foaf:name ?_creatorName + } + ?catalog ?_lastModifiedInLOVAt + } + GROUP BY ?uri ?catalog + SPARQL + response = sparql_query(query, 'text/csv') + end + private + + def parse_json_response(response_body) + JSON.parse(response_body)["results"]["bindings"] + end + end +end + def logger(text, &block) - puts ">> #{text} starting..." + puts ">> #{text} starting..." time = Benchmark.realtime do block.call end puts "#{text} finished in #{time} seconds" end - + def main + parser = LOVMigrator::SparqlParser.new() end -main \ No newline at end of file +main + From 070e69bb2a0a65f2a5a79b333b75def7aaa60d0b Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 29 Oct 2024 13:06:02 +0100 Subject: [PATCH 03/17] add Vocabularies export to csv --- bin/lov_migrator | 55 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index 60e6fc85..9bf39976 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -31,8 +31,11 @@ require 'net/http' require 'json' require 'date' require 'benchmark' - +require 'csv' LOV_ENDPOINT = "http://localhost:3030/lov" +CSV_ADDED_ATTRS = [ 'destination', 'who', 'comment' ] +CSV_DISPATCH_FILENAME = 'LOV_vocabularies.csv' +CSV_FILENAME = "vocabs.csv" class LOVMigrator @@ -119,6 +122,56 @@ class LOVMigrator JSON.parse(response_body)["results"]["bindings"] end end + + class CSVGenerator + attr_reader :csv_file_path, :csv_content + + def initialize(csv_content) + @csv_file_path = CSV_DISPATCH_FILENAME + @csv_content = csv_content + @csv_file_data = load_csv_file + end + + # Load CSV file into a hash for easy lookups + def load_csv_file + data = {} + CSV.foreach(@csv_file_path, headers: true) do |row| + data[row['prefix']] = row.to_h # assuming 'prefix' is a unique prefixentifier + end + data + end + + # Parse CSV string + def parse_csv_content + CSV.parse(@csv_content, headers: true) + end + + # Modify CSV string data based on values in the file data + def copy_added_values_to_csv + csv_data = parse_csv_content + csv_data.each do |row| + if @csv_file_data.key?(row['prefix']) + CSV_ADDED_ATTRS.each do |attr| + row[attr] = @csv_file_data[row['prefix']][attr] + end + end + end + csv_data + end + + # Save modified CSV data to a new file + def save_to_csv(csv_file_path = CSV_FILENAME) + modified_data = copy_added_values_to_csv + CSV.open(csv_file_path, 'w', write_headers: true, headers: modified_data.headers) do |csv| + modified_data.each do |row| + csv << row + end + end + puts "Modifications saved to #{csv_file_path}" + end + end + + end def logger(text, &block) From c79c08bb98bf96773143f5cbe2233f9d16e1e4b7 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 29 Oct 2024 13:07:32 +0100 Subject: [PATCH 04/17] Using module instead of class --- bin/lov_migrator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index 9bf39976..4336cde1 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -37,8 +37,8 @@ CSV_ADDED_ATTRS = [ 'destination', 'who', 'comment' ] CSV_DISPATCH_FILENAME = 'LOV_vocabularies.csv' CSV_FILENAME = "vocabs.csv" +module LOVMigrator -class LOVMigrator attr_accessor :lov_endpoint class SparqlParser def initialize(endpoint = LOV_ENDPOINT) From 7ae46514781fefd08ec53d0c8d0644a9934f1b76 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 29 Oct 2024 13:14:01 +0100 Subject: [PATCH 05/17] Add check for remote changes in LOV --- bin/lov_migrator | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/lov_migrator b/bin/lov_migrator index 4336cde1..4a19aff3 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -41,12 +41,17 @@ module LOVMigrator attr_accessor :lov_endpoint class SparqlParser + attr_accessor :last_processed_date def initialize(endpoint = LOV_ENDPOINT) @lov_endpoint = endpoint _last_processed_date_file = ".last_processed_date.txt" @last_processed_date = File.exist?(_last_processed_date_file) ? Date.parse(File.read(_last_processed_date_file).strip) : nil end + def remote_changes? + @last_processed_date && @last_processed_date < latest_remote_modification_date + end + def sparql_query(query, accept_format = 'application/sparql-results+json') uri = URI.parse("#{@lov_endpoint}/sparql") From 2e2950e6f88c397ad8f92acb335b88f123888346 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 29 Oct 2024 13:14:54 +0100 Subject: [PATCH 06/17] add main function --- bin/lov_migrator | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bin/lov_migrator b/bin/lov_migrator index 4a19aff3..59254d0c 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -189,6 +189,23 @@ end def main parser = LOVMigrator::SparqlParser.new() + + logger("Checking for new cahnges") do + if not parser.remote_changes? + puts "No changes occured since #{parser.last_processed_date}" + exit + end + end + vocabularies = "" + logger("Start fetching Vocabularies ...") do + vocabularies = parser.fetch_all_vocabs + end + logger("Start creating CSV #{CSV_FILENAME}") do + csvGen = LOVMigrator::CSVGenerator.new(vocabularies) + csvGen.save_to_csv + end + + end main From 70563b12f3c44598a20f8ea0f7fce813c313484a Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 29 Oct 2024 14:54:57 +0100 Subject: [PATCH 07/17] add LOV endpoint --- bin/lov_migrator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index 59254d0c..5236e2b6 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -32,7 +32,7 @@ require 'json' require 'date' require 'benchmark' require 'csv' -LOV_ENDPOINT = "http://localhost:3030/lov" +LOV_ENDPOINT = "https://lov.linkeddata.es/dataset/lov" CSV_ADDED_ATTRS = [ 'destination', 'who', 'comment' ] CSV_DISPATCH_FILENAME = 'LOV_vocabularies.csv' CSV_FILENAME = "vocabs.csv" From a5aefd258eceee57c24dc1c1cd26e034d0e1e1e3 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 29 Oct 2024 16:00:25 +0100 Subject: [PATCH 08/17] fix to handle when there is no last_processed_date file --- bin/lov_migrator | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index 5236e2b6..df81f7e4 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -49,7 +49,8 @@ module LOVMigrator end def remote_changes? - @last_processed_date && @last_processed_date < latest_remote_modification_date + return true unless @last_processed_date + @last_processed_date < latest_remote_modification_date end def sparql_query(query, accept_format = 'application/sparql-results+json') @@ -134,7 +135,7 @@ module LOVMigrator def initialize(csv_content) @csv_file_path = CSV_DISPATCH_FILENAME @csv_content = csv_content - @csv_file_data = load_csv_file + @csv_file_data = load_csv_file if File.exist?(@csv_file_path) end # Load CSV file into a hash for easy lookups @@ -154,6 +155,7 @@ module LOVMigrator # Modify CSV string data based on values in the file data def copy_added_values_to_csv csv_data = parse_csv_content + if File.exist?(@csv_file_path) csv_data.each do |row| if @csv_file_data.key?(row['prefix']) CSV_ADDED_ATTRS.each do |attr| @@ -161,6 +163,7 @@ module LOVMigrator end end end + end csv_data end From 158f353970a96d39f2b36304378c7f8c3e5fe631 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 29 Oct 2024 16:31:08 +0100 Subject: [PATCH 09/17] fixing typo in text --- bin/lov_migrator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index df81f7e4..0107e57a 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -193,7 +193,7 @@ end def main parser = LOVMigrator::SparqlParser.new() - logger("Checking for new cahnges") do + logger("Checking for new changes") do if not parser.remote_changes? puts "No changes occured since #{parser.last_processed_date}" exit From 5e3a0dbe82b7718e03f3b123c6caf135d052a6ee Mon Sep 17 00:00:00 2001 From: Muhammad Date: Thu, 31 Oct 2024 10:20:26 +0100 Subject: [PATCH 10/17] make `last_processed_date` as instance variable --- bin/lov_migrator | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index 0107e57a..5077d46f 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -44,8 +44,8 @@ module LOVMigrator attr_accessor :last_processed_date def initialize(endpoint = LOV_ENDPOINT) @lov_endpoint = endpoint - _last_processed_date_file = ".last_processed_date.txt" - @last_processed_date = File.exist?(_last_processed_date_file) ? Date.parse(File.read(_last_processed_date_file).strip) : nil + @last_processed_date_file = ".last_processed_date.txt" + @last_processed_date = File.exist?(@last_processed_date_file) ? Date.parse(File.read(@last_processed_date_file).strip) : nil end def remote_changes? From 760b7620962f8004cc37b29778880e9ed7efb60a Mon Sep 17 00:00:00 2001 From: Muhammad Date: Thu, 31 Oct 2024 10:23:38 +0100 Subject: [PATCH 11/17] save the `last_processed_date` to a local file --- bin/lov_migrator | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index 5077d46f..43a784c4 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -122,6 +122,11 @@ module LOVMigrator SPARQL response = sparql_query(query, 'text/csv') end + def update_latest_modification_date + File.open(@last_processed_date_file, "w") do |file| + file.puts Date.today + end + end private def parse_json_response(response_body) @@ -207,8 +212,7 @@ def main csvGen = LOVMigrator::CSVGenerator.new(vocabularies) csvGen.save_to_csv end - - + parser.update_latest_modification_date end main From f44d1dc3e4a624ff2db27698b8e81c1a2511a07a Mon Sep 17 00:00:00 2001 From: Muhammad Date: Thu, 31 Oct 2024 10:24:23 +0100 Subject: [PATCH 12/17] print the modified Vocabularies after the last processed date --- bin/lov_migrator | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/lov_migrator b/bin/lov_migrator index 43a784c4..2f90b28a 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -127,6 +127,20 @@ module LOVMigrator file.puts Date.today end end + + def fetch_latest_changed_vocabs + query = <<~SPARQL + SELECT ?catalogRecord + WHERE { + ?catalogRecord a . + ?catalogRecord ?modified. + FILTER(?modified > "#{@last_processed_date}"^^) + } + ORDER BY DESC(?modified) + SPARQL + response = sparql_query(query) + response.map.with_index {|response, index| "[#{index+1}] #{response['catalogRecord']['value']}"} + end private def parse_json_response(response_body) @@ -202,6 +216,11 @@ def main if not parser.remote_changes? puts "No changes occured since #{parser.last_processed_date}" exit + else + if parser.last_processed_date + puts "The following vocabs were changed since #{parser.last_processed_date}" + puts parser.fetch_latest_changed_vocabs + end end end vocabularies = "" From a74b855582b31ce95c53f78a1a3e5c2db168817a Mon Sep 17 00:00:00 2001 From: Muhammad Date: Mon, 4 Nov 2024 07:21:28 +0100 Subject: [PATCH 13/17] add LOV vocabularies dispatch CSV file as a script argument --- bin/lov_migrator | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index 2f90b28a..b7fa06d7 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -14,8 +14,8 @@ OptionParser.new do |opts| opts.on('-v', '--vocabularies PREFIX1, PREFIX2', 'Comma-separated list of vocabularies to update or import') do |acronym| ontologies_acronyms = acronym end - opts.on('--dispatch-csv') do |csv| - options[:csv_dispatch_filename] = csv + opts.on('--dispatch-csv FILENAME', 'Specify the CSV file to dispatch') do |csv_file| + options[:csv_dispatch_filename] = csv_file end # Display the help screen, all programs are assumed to have this option. opts.on( '-h', '--help', 'Display this screen' ) do @@ -151,8 +151,8 @@ module LOVMigrator class CSVGenerator attr_reader :csv_file_path, :csv_content - def initialize(csv_content) - @csv_file_path = CSV_DISPATCH_FILENAME + def initialize(csv_content, csv_file_path = nil) + @csv_file_path = csv_file_path @csv_content = csv_content @csv_file_data = load_csv_file if File.exist?(@csv_file_path) end @@ -209,7 +209,7 @@ def logger(text, &block) puts "#{text} finished in #{time} seconds" end -def main +def main(options) parser = LOVMigrator::SparqlParser.new() logger("Checking for new changes") do @@ -228,11 +228,11 @@ def main vocabularies = parser.fetch_all_vocabs end logger("Start creating CSV #{CSV_FILENAME}") do - csvGen = LOVMigrator::CSVGenerator.new(vocabularies) + csvGen = LOVMigrator::CSVGenerator.new(vocabularies, options[:csv_dispatch_filename]) csvGen.save_to_csv end parser.update_latest_modification_date end -main +main(options) From dc9256ff66f7a7404c5bb378c0b801031607ff53 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Thu, 7 Nov 2024 08:35:43 +0100 Subject: [PATCH 14/17] Wrapping values in csv between quotes to not break the format --- bin/lov_migrator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index b7fa06d7..de9e4d08 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -189,7 +189,7 @@ module LOVMigrator # Save modified CSV data to a new file def save_to_csv(csv_file_path = CSV_FILENAME) modified_data = copy_added_values_to_csv - CSV.open(csv_file_path, 'w', write_headers: true, headers: modified_data.headers) do |csv| + CSV.open(csv_file_path, 'w', write_headers: true, headers: modified_data.headers, force_quotes: true) do |csv| modified_data.each do |row| csv << row end From 54a38620c0baa754393ab425a2415ac2d86cce6a Mon Sep 17 00:00:00 2001 From: Muhammad Date: Thu, 7 Nov 2024 08:51:46 +0100 Subject: [PATCH 15/17] Store lov_last_processed_date.txt at `/vat/tmp` and use a full path --- bin/lov_migrator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index de9e4d08..2d3ef09d 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -44,7 +44,7 @@ module LOVMigrator attr_accessor :last_processed_date def initialize(endpoint = LOV_ENDPOINT) @lov_endpoint = endpoint - @last_processed_date_file = ".last_processed_date.txt" + @last_processed_date_file = "/var/tmp/.lov_last_processed_date.txt" @last_processed_date = File.exist?(@last_processed_date_file) ? Date.parse(File.read(@last_processed_date_file).strip) : nil end From 9b5a28673bf12c76b7a2c646f244925e4e85ad9d Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 10 Dec 2024 20:02:31 +0100 Subject: [PATCH 16/17] Add support for last processed date as argument --- bin/lov_migrator | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index 2d3ef09d..a5b85f46 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -17,6 +17,14 @@ OptionParser.new do |opts| opts.on('--dispatch-csv FILENAME', 'Specify the CSV file to dispatch') do |csv_file| options[:csv_dispatch_filename] = csv_file end + opts.on('--date DATE', 'Fetch vocabularies changed since this date (YYYY-MM-DD)') do |date| + begin + options[:date] = Date.parse(date).to_s + rescue ArgumentError + puts "Invalid date format. Please use YYYY-MM-DD." + exit 1 + end + end # Display the help screen, all programs are assumed to have this option. opts.on( '-h', '--help', 'Display this screen' ) do puts opts @@ -42,10 +50,18 @@ module LOVMigrator attr_accessor :lov_endpoint class SparqlParser attr_accessor :last_processed_date - def initialize(endpoint = LOV_ENDPOINT) + + def initialize(endpoint, date_arg = nil) @lov_endpoint = endpoint @last_processed_date_file = "/var/tmp/.lov_last_processed_date.txt" - @last_processed_date = File.exist?(@last_processed_date_file) ? Date.parse(File.read(@last_processed_date_file).strip) : nil + # Determine the last processed date + if date_arg + @last_processed_date = Date.parse(date_arg) # Use the argument if provided + elsif File.exist?(@last_processed_date_file) + @last_processed_date = Date.parse(File.read(@last_processed_date_file).strip) # Fallback to the file value + else + @last_processed_date = nil # No date available + end end def remote_changes? @@ -210,8 +226,7 @@ def logger(text, &block) end def main(options) - parser = LOVMigrator::SparqlParser.new() - + parser = LOVMigrator::SparqlParser.new(endpoint = LOV_ENDPOINT, date_arg = options[:date]) logger("Checking for new changes") do if not parser.remote_changes? puts "No changes occured since #{parser.last_processed_date}" From f36dc77d9f875338de8a75a191b96b5eb72a7801 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 10 Dec 2024 21:16:44 +0100 Subject: [PATCH 17/17] make prefix and title values unique & add language filter --- bin/lov_migrator | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/lov_migrator b/bin/lov_migrator index a5b85f46..2907181e 100755 --- a/bin/lov_migrator +++ b/bin/lov_migrator @@ -111,8 +111,8 @@ module LOVMigrator PREFIX dct: SELECT DISTINCT - (GROUP_CONCAT(DISTINCT ?_prefix; separator="\\n") AS ?prefix) - (GROUP_CONCAT(DISTINCT ?_title; separator="\\n") AS ?title) + (GROUP_CONCAT(DISTINCT STR(?_prefix); separator="\\n") AS ?prefix) + (GROUP_CONCAT(DISTINCT STR(?_title); separator="\\n") AS ?title) (GROUP_CONCAT(DISTINCT ?_description; separator="\\n") AS ?description) (GROUP_CONCAT(DISTINCT ?_keyword; separator="\\n") AS ?keyword) (GROUP_CONCAT(DISTINCT ?_creatorName; separator="\\n") AS ?creator) @@ -133,6 +133,7 @@ module LOVMigrator ?_creator foaf:name ?_creatorName } ?catalog ?_lastModifiedInLOVAt + FILTER(lang(?_title) = "en") } GROUP BY ?uri ?catalog SPARQL