File: example-federated.py

package info (click to toggle)
sparql-wrapper-python 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,228 kB
  • sloc: python: 14,201; makefile: 30
file content (28 lines) | stat: -rw-r--r-- 826 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python
# -*- coding: utf-8 -*-

from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://agrovoc.uniroma2.it:3030/agrovoc/sparql")

query = """
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT ?conceptAGROVOC ?conceptGEMET ?label
WHERE {
    ?conceptAGROVOC rdf:type skos:Concept ;
                    skos:prefLabel ?label;
                    skos:inScheme <http://voc.landportal.info/landterms> .
    FILTER (lang(?label) = 'en')

    SERVICE <http://semantic.eea.europa.eu/sparql> { 
            ?conceptGEMET skos:prefLabel ?label ; 
            skos:inScheme <http://www.eionet.europa.eu/gemet/gemetThesaurus> .
    } 
}
"""
sparql.setQuery(query)
sparql.setReturnFormat(JSON)

results = sparql.query().print_results()