RDF imports

RDF imports and transforming RDF using SPARQL CONSTRUCT

If you are ready to import some RDF, see our step-by-step tutorial on creating an RDF import.

A data import is a combination of 3 resources:

File
An uploaded file holding the data to be converted to RDF and imported, such as CSV or RDF file
Mapping
The CONSTRUCT query that produces RDF
Target container
The container to which converted items will be POSTed, skolemized against, and become its children

The import process runs in the background, i.e. the import item is created before the process completes. Currently the only way to determine when it completes is to refresh the import item and check the import status (completed/failed). Upon successful report, metadata such as the number of imported RDF triples is attached to the import.

The converted RDF is validated against constraints before import. Constraint violations, if any, are attached to the import item.

Import RDF

Lets assume we want to import SKOS concept data:

@prefix : <http://vocabularies.unesco.org/thesaurus/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:concept10 a skos:Concept ;
    dcterms:modified "2006-05-23T00:00:00"^^xsd:dateTime ;
    skos:inScheme <http://vocabularies.unesco.org/thesaurus> ;
    skos:narrower :concept4938 , :concept7597 ;
    skos:prefLabel "Right to education"@en , "Droit à l'éducation"@fr , "Derecho a la educación"@es , "Право на образование"@ru ;
    skos:related :concept9 , :concept556 , :concept557 , :concept1519 , :concept5052 ;
    skos:topConceptOf <http://vocabularies.unesco.org/thesaurus> .

:concept1000 a skos:Concept ;
    dcterms:modified "2006-05-23T00:00:00"^^xsd:dateTime ;
    skos:broader :concept389 ;
    skos:inScheme <http://vocabularies.unesco.org/thesaurus> ;
    skos:prefLabel "Talent"@en , "Talent"@fr , "Talento"@es , "Талант"@ru ;
    skos:related :concept993 , :concept996 , :concept3086 .

:concept10003 a skos:Concept ;
    dcterms:modified "2006-05-23T00:00:00"^^xsd:dateTime ;
    skos:altLabel "Entrevue"@fr ;
    skos:broader :concept4725 ;
    skos:inScheme <http://vocabularies.unesco.org/thesaurus> ;
    skos:prefLabel "Interviews"@en , "Entretien"@fr , "Entrevista"@es , "Интервью"@ru .

Transformation

This step is used to transform the RDF data that is being imported, if necessary (to a different vocabulary, for example). It also connects instances in the imported data to the documents in LinkedDataHub's dataset.

The mapping is a user-defined SPARQL CONSTRUCT. In this case we give each SKOS concept from the imported dataset an additional RDF type and pair the concept with its item (document):

PREFIX dom:   <ns/domain#>
PREFIX dh:    <https://www.w3.org/ns/ldt/document-hierarchy/domain#>
PREFIX sioc:  <http://rdfs.org/sioc/ns#>
PREFIX foaf:  <http://xmlns.com/foaf/0.1/>
PREFIX skos:  <http://www.w3.org/2004/02/skos/core#>
PREFIX dct:   <http://purl.org/dc/terms/>

CONSTRUCT
{
    ?thing ?p ?o ;
        a ?type ;
        foaf:isPrimaryTopicOf ?item ;
        ?p ?o .
    ?item a ?itemType ;
        sioc:has_container ?container ;
        dh:slug ?id ;
        dct:title ?prefLabel ;
        foaf:primaryTopic ?thing .
}
WHERE
{
    SELECT *
    {
        {
            ?thing a skos:Concept
            BIND (dom:Concept AS ?type)
            BIND (dom:ConceptItem AS ?itemType)
            BIND (<concepts/> AS ?container)
        }
        UNION
        {
            ?thing a skos:ConceptScheme
            BIND (dom:ConceptScheme AS ?type)
            BIND (dom:ConceptSchemeItem AS ?itemType)
            BIND (<concept-schemes/> AS ?container)
        }
        BIND(struuid() AS ?id)
        BIND(BNODE() AS ?item)
        ?thing ?p ?o
        OPTIONAL
        {
            ?thing skos:prefLabel ?prefLabel
            FILTER (langMatches(lang(?prefLabel), "en"))
        }
    }
}

These are the rules that hold for mapping queries:

  • BASE value is set to the application's base URI
  • ?this binding is set to the value of the target container
  • produce items (documents) and pair them with topic resources using foaf:primaryTopic/foaf:isPrimaryTopicOf properties
  • useOPTIONAL for optional cell values
  • use BIND() to introduce new values and/or cast literals to the appropriate result datatype or URI

Blank node resources in the output will be skolemized depending on their RDF types.

We are planning to provide a UI-based mapping tool in the future.

The result of our mapping using:

@prefix : <http://vocabularies.unesco.org/thesaurus/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix sioc: <http://rdfs.org/sioc/ns#> .
@prefix dh: <https://www.w3.org/ns/ldt/document-hierarchy/domain#> .
@prefix dom: <ns/domain#> .

:concept10 a skos:Concept, dom:Concept ;
    dcterms:modified "2006-05-23T00:00:00"^^xsd:dateTime ;
    skos:inScheme <http://vocabularies.unesco.org/thesaurus> ;
    skos:narrower :concept4938 , :concept7597 ;
    skos:prefLabel "Right to education"@en , "Droit à l'éducation"@fr , "Derecho a la educación"@es , "Право на образование"@ru ;
    skos:related :concept9 , :concept556 , :concept557 , :concept1519 , :concept5052 ;
    skos:topConceptOf <http://vocabularies.unesco.org/thesaurus> ;
    foaf:isPrimaryTopicOf <concepts/c499e66a-8036-4637-929d-0d809177883e/> .

<concepts/c499e66a-8036-4637-929d-0d809177883e/> a dom:ConceptItem ;
    sioc:has_container <concepts/> ;
    dh:slug "c499e66a-8036-4637-929d-0d809177883e" ;
    dcterms:title "Right to education"@en ;
    foaf:primaryTopic :concept10 .

:concept1000 a skos:Concept, dom:Concept ;
    dcterms:modified "2006-05-23T00:00:00"^^xsd:dateTime ;
    skos:broader :concept389 ;
    skos:inScheme <http://vocabularies.unesco.org/thesaurus> ;
    skos:prefLabel "Talent"@en , "Talent"@fr , "Talento"@es , "Талант"@ru ;
    skos:related :concept993 , :concept996 , :concept3086 ;
    foaf:isPrimaryTopicOf <concepts/f41910fa-9077-4656-8f73-752fd923a79b/> .

<concepts/f41910fa-9077-4656-8f73-752fd923a79b/> a dom:ConceptItem ;
    sioc:has_container <concepts/> ;
    dh:slug "f41910fa-9077-4656-8f73-752fd923a79b" ;
    dcterms:title "Talent"@en ;
    foaf:primaryTopic :concept1000 .

:concept10003 a skos:Concept, dom:Concept ;
    dcterms:modified "2006-05-23T00:00:00"^^xsd:dateTime ;
    skos:altLabel "Entrevue"@fr ;
    skos:broader :concept4725 ;
    skos:inScheme <http://vocabularies.unesco.org/thesaurus> ;
    skos:prefLabel "Interviews"@en , "Entretien"@fr , "Entrevista"@es , "Интервью"@ru ;
    foaf:isPrimaryTopicOf <concepts/2afb2e06-5081-4db1-9255-660fcd1b3ec8/> .

<concepts/2afb2e06-5081-4db1-9255-660fcd1b3ec8/> a dom:ConceptItem ;
    sioc:has_container <concepts/> ;
    dh:slug "2afb2e06-5081-4db1-9255-660fcd1b3ec8" ;
    dcterms:title "Interviews"@en ;
    foaf:primaryTopic :concept10003 .