Project:QuickStatements: Difference between revisions
From MaRDI portal
Line 8: | Line 8: | ||
## The thing you want to export, here a part of the external url P205 | ## The thing you want to export, here a part of the external url P205 | ||
# Write the query, example <syntaxhighlight lang=sparql> | # Write the query, example <syntaxhighlight lang=sparql> | ||
SELECT ? | SELECT ?MaRDI_qID ?MaRDI_item ?EuDMLid WHERE { | ||
? | ?MaRDI_item wdt:P205 ?URL; | ||
wdt:P12 ?MaRDI_qID. | |||
FILTER (STRSTARTS( | FILTER(STRSTARTS(STR(?URL), "https://eudml")) | ||
BIND ( | BIND(SUBSTR(STR(?URL), 23 ) AS ?EuDMLid) | ||
} | } | ||
LIMIT 10 | LIMIT 10 |
Revision as of 10:06, 7 October 2024
Data transfer to Wikidata
This section describes how to export data from the MaRDI portal to Wikidata to make the data better findable for the general public.
Example EuDML prposed by Vladimir Alexiev in 2022, which has currently 17 results.
- Prepare query for the MaRDI SPARQL endpoint
- Find the qIDs P12 = WikidataQId
- The thing you want to export, here a part of the external url P205
- Write the query, example and investiage the result.
SELECT ?MaRDI_qID ?MaRDI_item ?EuDMLid WHERE { ?MaRDI_item wdt:P205 ?URL; wdt:P12 ?MaRDI_qID. FILTER(STRSTARTS(STR(?URL), "https://eudml")) BIND(SUBSTR(STR(?URL), 23 ) AS ?EuDMLid) } LIMIT 10
- Find the properties in Wikidata, here only P11166 for eudml.
- Rewrite the query to match the Quickstatements CSV format
SELECT ?qid ?P11166 WHERE { ?qal854 wdt:P205 ?url ; wdt:P12 ?qid FILTER (STRSTARTS(str(?url) ,"https://eudml")) . BIND (Concat( "\"", ## Required for external identifiers by quickstatements SUBSTR(STR(?url),23), ## 23 = Length of the prefix "\"") as ?P11166) } LIMIT 3
- Download the CSV file and test with a few items on Wikidata
- Optional add source linking back to the source of the information (MaRDI)
SELECT ?qid ?P11166 ?S854 WHERE { ?item wdt:P205 ?url ; wdt:P12 ?qid FILTER (STRSTARTS(str(?url) ,"https://eudml")) . BIND (Concat( "\"", ## Required for external identifiers by quickstatements SUBSTR(STR(?url),23), ## 23 = Length of the prefix "\"") as ?P11166). BIND (Concat( "\"", ## Required for external identifiers by quickstatements STR(?item), "\"") as ?S854) } LIMIT 3
- Remove the limit and do the full import