migrants/updates/006-migration_table-reason2.rq
Daniel Hernandez d2481d6e80 Add Step 2: SPARQL UPDATE queries to transform literals into objects.
19 queries in updates/ convert categorical columns (continent, country,
city, gender, profession, etc.) from literals to typed RDF objects with
rdfs:label. map/step-02.rb applies them to produce data/graph-02.ttl.
Also fix step-01.rb to sanitize column names with spaces and avoid
prefix serialization issues with fragment IRIs.
2026-02-26 19:45:08 +01:00

15 lines
527 B
SPARQL

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
DELETE {
?s <http://example.org/migrants/migration_table#reason2> ?val .
}
INSERT {
?s <http://example.org/migrants/migration_table#reason2> ?obj .
?obj a <http://example.org/migrants/MigrationReason> .
?obj rdfs:label ?label .
}
WHERE {
?s <http://example.org/migrants/migration_table#reason2> ?val .
BIND(IRI(CONCAT("http://example.org/migrants/MigrationReason-", ENCODE_FOR_URI(REPLACE(?val, " ", "")))) AS ?obj)
BIND(STRLANG(STR(?val), "en") AS ?label)
}