Project:RedirectionScript: Difference between revisions
From MaRDI portal
No edit summary |
No edit summary |
||
| Line 20: | Line 20: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Get all items that are referencing one that is sameAs another === | === Get all items that are referencing one that is sameAs another, but not over sameAs relationship === | ||
<syntaxhighlight lang="sparql"> | --> this means I want to get all that reference an out of date link<syntaxhighlight lang="sparql"> | ||
SELECT DISTINCT ?o ?oLabel ?sa ?item ?itemLabel ?property ?propertyLabel | SELECT DISTINCT ?o ?oLabel ?sa ?item ?itemLabel ?property ?propertyLabel | ||
WHERE { | WHERE { | ||
Latest revision as of 16:08, 20 November 2025
SPARQL queries
Count number of items that redirect to another item
SELECT (COUNT (DISTINCT ?original) AS ?count)
WHERE
{
?original owl:sameAs ?new .
}
Get mapping of original items to the ones they were redirected to
This query gets all original items (?o) that get redirected to another item (?sa). We need these results because for each original item, the script looks for items that link to it. Then, it replaces the link on these original items with a link to the ?sa item.
SELECT DISTINCT ?original ?new
WHERE
{
?original owl:sameAs ?new .
}
Get all items that are referencing one that is sameAs another, but not over sameAs relationship
--> this means I want to get all that reference an out of date link
SELECT DISTINCT ?o ?oLabel ?sa ?item ?itemLabel ?property ?propertyLabel
WHERE {
# Get all sameAs mappings
?o owl:sameAs ?sa .
# Find items that point to ?o via any property except owl:sameAs
?item ?property ?o .
FILTER(?property != owl:sameAs)
}
Script
https://github.com/MaRDI4NFDI/docker-importer/blob/main/bot_scripts/reroute.py
The script takes as input a csv file with the output of the second sparql query that maps old ids to new ids.
Potential Problems
If for a specific item, the problem is not fixed after executing this script, it might be that the item was not correctly indexed. This can be fixed by using Project:RerunUpdate and then rerunning the script.