Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wikidata: SPARQL Select items only if they do not include a property

Problem #1

To find people I use

SELECT ?item WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q5.
}

but to find people still alive I would like to exclude people have not defined one among this property 570, 509, 20. how can I do?

Problem #2

To find tennis tournaments I use

SELECT ?item
WHERE
{
  ?item wdt:P31 wd:Q13219666.
}

Unfortunately, some tournaments are not identified directly and therefore use:

SELECT ?item
WHERE
{
  ?item wdt:P31/wdt:P279 wd:Q13219666.
}

However, I am also returned to the editions of a tournament, such as '2000 wimbledon', '2001 wimbledon', etc while I would like to get only 'wimbledon'. How can I do?

Thank you

like image 202
Amedeo Avatar asked Oct 26 '25 21:10

Amedeo


1 Answers

As offered in comments...

#1 by @aksw

FILTER NOT EXISTS {?item wdt:P570|wdt:P509|wdt:P20 ?o}

#2 by @stanislav-kralin

This is a data quality problem. This appears to be a workaround:

SELECT DISTINCT ?item ?itemLabel 
WHERE { ?item  wdt:P31?/wdt:P279?  wd:Q13219666 . 
        FILTER NOT EXISTS { ?item  wdt:P585  [] } 
        SERVICE wikibase:label 
          { bd:serviceParam  wikibase:language  "en" . } 
      } 
# uncomment the following line if desired
      # VALUES (?item) { (wd:Q41520) }
like image 172
TallTed Avatar answered Oct 29 '25 19:10

TallTed