Project:RedirectionScript: Difference between revisions
From MaRDI portal
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 21: | Line 21: | ||
=== Get all items that redirect to somewhere else and are still referenced in another item === | === Get all items that redirect to somewhere else and are still referenced in another item === | ||
<syntaxhighlight lang="sparql"> | Exclude those without a label to exclude other reference pages<syntaxhighlight lang="sparql"> | ||
SELECT DISTINCT ?o | SELECT DISTINCT ?o | ||
WHERE | WHERE | ||
{ | { | ||
?o owl:sameAs ?sa . | ?o owl:sameAs ?sa . | ||
?new ?p ?o | ?new ?p ?o . | ||
?o rdfs:label ?label . | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 32: | Line 33: | ||
== Script == | == Script == | ||
https://github.com/MaRDI4NFDI/docker-importer/blob/main/bot_scripts/reroute.py | 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. |
Latest revision as of 09:38, 14 March 2024
SPARQL queries
Count number of items that redirect to another item
SELECT (COUNT (DISTINCT ?o) AS ?count)
WHERE
{
?o owl:sameAs ?sa .
}
Get mapping of original items to the ones they were redirected to
SELECT DISTINCT ?o ?sa
WHERE
{
?o owl:sameAs ?sa .
}
Get all items that redirect to somewhere else and are still referenced in another item
Exclude those without a label to exclude other reference pages
SELECT DISTINCT ?o
WHERE
{
?o owl:sameAs ?sa .
?new ?p ?o .
?o rdfs:label ?label .
}
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.