Hi,
On 05.04.2017 19:07, Stas Malyshev wrote:
Hi!
Hi all,
I am building a Question Answering System for Wikidata (I will put the
demo live in May) and would like to be able to ask quesitons like "Give
me the cities in Alaska". To query Wikidata I am using the Wikidata
SPARQL endpoint.
The SPARQL query for this question looks the following way [0]:
SELECT DISTINCT ?x ?xLabel
{
# All things in Alaska
?x (wdt:P131+ | wdt:P276) wd:Q797 .
# All cities
?x ((wdt:P106 | wdt:P39 | wdt:P31) / wdt:P279*) wd:Q515 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
I'm not sure why you are using P106 or P39 for cities. If some data has
it, it's almost certainly an error - city can not hold a position or
have an occupation. Using P276 is usually an error too.
For the query, I'd suggest this one:
http://tinyurl.com/m5dtwax Thank you, the
hint helped. (I forgot to remove the P106 and P39, they
are some remains from the system)
Best,
Anatoly Zelenin