File: wikidata.py

package info (click to toggle)
rudof 0.1.146%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 10,048 kB
  • sloc: python: 1,288; makefile: 32; sh: 1
file content (19 lines) | stat: -rw-r--r-- 531 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from pyrudof import Rudof, RudofConfig, RDFFormat 

query = """
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT ?person ?occupation WHERE {
    ?p wdt:P31 wd:Q5 ;   
          wdt:P106 ?o ;
          rdfs:label ?person ;
          wdt:P19 wd:Q14317 .
  ?o rdfs:label ?occupation 
  FILTER (lang(?person) = "en" && lang(?occupation) = "en")   
}
LIMIT 10
"""
rudof = Rudof(RudofConfig())
rudof.use_endpoint("wikidata")
results = rudof.run_query_str(query)
print(results.show())