0

I made my SPARQL query below in the Wikidata Query Service and got the responses which is different from what I am expected. The query below is intended to extract the all countries that are member of OECD Organization for Economic Co-operation and Development. Actually the count of members should be 35. but the query results is only 16. For example, the country Spain is the member of OECD as well, and in the wikidata page, Spain is properly written so. In fact, Spain is instanceof(P031) country(Q6256), and has OECD(Q41550) item as object in the memberof (P463) property in the wikidata page. To my best understanding, Spain should be in the result set, but isn't in fact shown in my query result. I am very confused now to try to find out what parts in the query I should modify to the the proper answer. (I'd like to fix the query from the general SPARQL point of view as long as I can.)

Would you somebody help and correct the query below to get the proper 35 countries? Thank you for your kind help in advance.

SELECT ?s ?sLabel ?p 
WHERE {
  BIND(wd:Q41550 AS ?o)
  BIND(wdt:P31 AS ?instanceof)
  BIND(wd:Q6256 AS ?class)
  #template
    ?s ?p ?o.
    ?s ?instanceof ?class
  

   SERVICE wikibase:label {
    bd:serviceParam wikibase:language "ko,[AUTO_LANGUAGE]" .
  }
}

Try it

logi-kal
  • 7,107
  • 6
  • 31
  • 43
Keanu Paik
  • 304
  • 2
  • 12
  • Oh, now I understand the internals. Than you for your kindness. I didn't know the Best Rank stuff. However, so how I can get the update result? Still confused. In the query above, Spain is still not country because spain is not checked as country. Spain is sovereign state as a Best Rank and is not considered as country. Literally, all the sovereign state is country, I think. To my best understanding, country is a super set of either sovereign state. Sovereign state or country, which is best (description) to Spain? I mean, best rank (Preferred rank) can make a possibly lot of trouble. – Keanu Paik Mar 23 '19 at 17:00
  • Try `SELECT ?s ?p {?s wdt:P463 wd:Q41550}` or `SELECT ?s ?sLabel ?p { ?s ?p wd:Q41550 . ?s p:P31/ps:P31 wd:Q6256 }`. – Stanislav Kralin Mar 23 '19 at 19:49
  • but the query triggers me 2 questions. First, the query retrieves most of the country but omits one country - Italy. I found that Italy is not 'instanceof' country in the wikidata. Also I found that either p:P31, or ps:P31 individually does not retrieve any result. However, p:P31/ps:P31 gets most of the country. Operator / means 'or' right? How can I explain such results? That's hard to understand. – Keanu Paik Mar 24 '19 at 01:59
  • The first one 3 people in the result, meaning the query still requires 'country' related filter. I am interested in the second one. – Keanu Paik Mar 24 '19 at 02:13
  • ```SELECT DISTINCT ?s ?sLabel WHERE{ ?s ?p wd:Q41550 . {?s p:P31/ps:P31 wd:Q6256 .} UNION {?s p:P31/ps:P31 wd:Q3624078 .} } ``` With this query I finally got the result that I expected initially. But the query looks 'less' intuitive and elapse much more time retrieving the results. And also requires DISTINCT. Should I do something like this? – Keanu Paik Mar 24 '19 at 02:16

0 Answers0