Publications Office of the EU
Federated queries - EU Vocabularies
DisplayCustomHeader
Semantic knowledge base - title

Semantic knowledge base

Weergave kennisbank

Federated queries

Federated queries do sound like a complex area of the semantic technologies environment but are quite simply to understand if approached by components.

We have designed an example of a federated query that perfectly describes how such a technique can make use of existing alignments to enrich one resource with properties found in another. In addition it does this by using an intermediary dataset. This example shows the power behind the Linked Open Data principles.

We have started with 3 resources:

  1. Country Authority table
  2. EuroVoc Thesaurus and
  3. Wikidata.org

Not all of them are linked directly, but alignments have been done between the following pairs:

  • EuroVoc – wikidata.org
  • EuroVoc - Country Authority table

The demonstration will make use of both alignments to associate a set of properties from wikidata.org to a concept found in the Country Authority table.

The objective will be to find some properties that define the concept Luxembourg, that in the Country Authority table is identified with the following URI: http://publications.europa.eu/resource/authority/country/LUX

The relation will be constructed using the two existing alignments and accessing the datasets thru their respective SPARQL endpoints.

The federated query will be executed on the SPARQL endpoint of the Publications Office ( http://publications.europa.eu/webapi/rdf/sparql ) where the Country Authority table can be found.

The other two resources will be accessed on their SPARQL endpoints as well:

In summary, the scope of the query is to add to a country concept fund in the Country Authority table a set of properties from wikidata.org, using the link that EuroVoc creates between those two resources.

The SPARQL script is listed below with the necessary comments to make it easy to understand.

PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX bd: <http://www.bigdata.com/rdf#>

# Define the structure of the result
SELECT ?countryLabel ?capital ?headOfGov ?population ?flag ?anthem ?geoshape

WHERE {

# Extract the EuroVoc URI of the concept from the Country Authority table
service <http://publications.europa.eu/webapi/rdf/sparql> {

    # Identify the EuroVoc ID of the Country concept    
    ?EuroVocID skos:closeMatch|skos:exactMatch <http://publications.europa.eu/resource/authority/country/LUX> .

    # Select the prefLabel (preferred label) of the concept
    ?EuroVocID skos:prefLabel ?countryLabel

    # Keep just the English version of the prefLabel
    FILTER (lang(?countryLabel)="en").
}

# Indicate the SPARQL endpoint where EuroVoc mappings can be found
service <http://publications.europa.eu/webapi/rdf/sparql> {

    # Get the Wikidata URI associated with the EuroVoc concepts
    ?EuroVocID skos:closeMatch|skos:exactMatch ?wikiURI .
}

# Look into the SPARQL endpoint of wikidata.org
service <https://query.wikidata.org/sparql> {

    # Get Wikidata properties associated with the URI
    ?wikiURI wdt:P36 ?capital .
    ?wikiURI wdt:P6 ?headOfGov .
    ?wikiURI wdt:P1082 ?population .
    ?wikiURI wdt:P41 ?flag .
    ?wikiURI wdt:P85 ?anthem .
    ?wikiURI wdt:P3896 ?geoshape
    }
}

 

Labels
authority tables interoperability semantic technologies sparql
Recentste
Dissemination formats 24 januari 2022
About reference data 23 oktober 2021
Resource alignments: Main elements of a proper methodology Vorige