On 4/21/15 6:05 PM, James Douglas
wrote:
Here's the (nearly) equivalent query for the statements
dump[1] loaded into Blazegraph:
PREFIX wd: <http://www.wikidata.org/entity/>
SELECT DISTINCT ?city ?citylabel ?mayorlabel WHERE {
?city wd:P31s/wd:P31v wd:Q515 . # find
instances of subclasses of city
?city wd:P6s ?statement . # with a
P6 (head of goverment) statement
?statement wd:P6v ?mayor . # ... that
has the value ?mayor
?mayor wd:P21s/wd:P21v wd:Q6581072 . # ...
where the ?mayor has P21 (sex or gender) female
FILTER NOT EXISTS { ?statement wd:P582q ?x } # ... but
the statement has no P582 (end date) qualifier
# Now select the population value of the ?city
# (the number is reached through a chain of three
properties)
?city wd:P1082s/wd:P1082v/<http://www.wikidata.org/ontology#numericValue>
?population .
# Optionally, find English labels for city and mayor:
OPTIONAL {
?city wd:P373s/wd:P373v ?citylabel .
# FILTER ( LANG(?citylabel) = "en" )
}
OPTIONAL {
?mayor wd:P373s/wd:P373v ?mayorlabel .
# FILTER ( LANG(?mayorlabel) = "en" )
}
} ORDER BY DESC(?population) LIMIT 100
Free beer to anyone who can figure out how to use those language
filters. Would we need to also load property definitions[2]?
Please try to share SPARQL related examples using SPARQL Query
Results URLs that identity documents where the content is
dynamically generated via SPARQL query processing. It makes them
easier to tweak and diagnose, amongst other things.
Examples:
1. http://bit.ly/wikidata-query-example-cities-with-female-mayor --
shortened query results url
BTW -- for language tags to work, the content would have to have
also been language tagged using "xyz"@en prior to upload to DBMS.
Then, modulo use of LANG filter, you would be seeing stuff like
"Madrid"@en in the output produced by the SELECT LIST.
Kingsley
_______________________________________________
Wikidata-l mailing list
Wikidata-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-l
--
Regards,
Kingsley Idehen
Founder & CEO
OpenLink Software
Company Web: http://www.openlinksw.com
Personal Weblog 1: http://kidehen.blogspot.com
Personal Weblog 2: http://www.openlinksw.com/blog/~kidehen
Twitter Profile: https://twitter.com/kidehen
Google+ Profile: https://plus.google.com/+KingsleyIdehen/about
LinkedIn Profile: http://www.linkedin.com/in/kidehen
Personal WebID: http://kingsley.idehen.net/dataspace/person/kidehen#this