- From: Lucas Werkmeister <mail@lucaswerkmeister.de>
- Date: Wed, 20 Jun 2018 19:32:59 +0200
- To: public-shex@w3.org
- Message-ID: <7e632131-d728-712c-3c7d-356a33f1d685@lucaswerkmeister.de>
This seems to work (omitting the prefixes for brevity): start = @<wikidata-organization> <wikidata-organization> { ( (wdt:P31 [wd:Q43229]; wdt:P31 .*) | (wdt:P31 @<subclass_of_organization>; wdt:P31 .*) ) } <subclass_of_organization> { ( (wdt:P279 [wd:Q43229]; wdt:P279 .*) | (wdt:P279 @<subclass_of_organization>; wdt:P279 .*) ) } I’m using the truthy statements here instead of the full statements, because that seems to make more sense to me and it slightly simplifies the ShEx, but I think the same approach could be made to work with full statements as well. Unfortunately, the target class (organization) has to be mentioned twice, in wikidata_organization and in subclass_of_organization, because I’m not aware of a way to declare that subclass_of_organization matches either a specific value or any value with these outgoing arcs. (I guess that would be a value set on the focus node? Is there such a thing?) All the triple constraints also mention that other values besides the required one are fine (the .* parts). I’m not sure why this ugly hack is necessary, but specifying the predicates as EXTRA doesn’t seem to be enough. I assume I don’t understand the intricacies of choices well enough yet :) Cheers, Lucas On 20.06.2018 19:11, Neubert, Joachim wrote: > > Hi, > > > > In my naive first approach for a „ How to get started with ShEx on > Wikidata? “ help page [1], I try to verify that every item with a > certain exernal id is an organization or some subtype of organization. > With a SPARQL query [2], that is quite straightforward – using a > property path - and reveals relevant results. > > > > However, in ShEx I have not been able to create a query to recursively > check if an instance is attached to any subclass of a given class. It > would be great if somebody could help out. My starting point was this [3]. > > > > Cheers, Joachim > > > > PS. While the restriction “some class or a subclass of it” will be > probably quite common in Wikidata, organization (wd:Q43229) may not be > the best demo example for an introduction: Currently it has more than > 19,000 subclasses [4] – often indeed instances. It may however serve > as a nasty case for tests. > > > > > > [1] > https://www.wikidata.org/wiki/User:Jneubert/How_to_get_started_with_ShEx_on_Wikidata%3F > > [2] > https://www.wikidata.org/wiki/User:Jneubert/Special_queries#PM20_type_%22co/%22_which_are_not_an_organization > > [3] > https://rawgit.com/shexSpec/shex.js/wikidata/doc/shex-simple.html?manifestURL=https://raw.githubusercontent.com/jneubert/wd-shex-test/master/dummy.manifest.json > > [4] > http://zbw.eu/beta/sparql-lab/?endpoint=https://query.wikidata.org/bigdata/namespace/wdq/sparql&queryRef=https://api.github.com/repos/zbw/sparql-queries/contents/wikidata/all_subclasses.rq > > >
Received on Wednesday, 20 June 2018 17:34:04 UTC