weso / scholiasub

Subsets of Wikidata based on Scholia and ShEx
0 stars 0 forks source link

Create a simple subset inspired on Country-authors SPARQL query #1

Open labra opened 3 years ago

labra commented 3 years ago

We can start with a query like:

PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>
PREFIX :    <http://www.wikidata.org/entity/>
PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wde:    <http://www.wikidata.org/entity/>

start=@:publication

:publication EXTRA wde:P31 {
    wde:P31 @:publication_type ;
    wde:P50 @:author *;
}

:author EXTRA wde:P31 {
    wde:P31 @:author_type ;
}

:author_type      [ wde:Q5 ]
:publication_type [ wde:Q732577 ]

However, @jorgealvarezfidalgo has been running the system and it seems that sparkwdsub only considers properties and not the values...he has been checking this ShEx:

PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
PREFIX :    <http://www.wikidata.org/entity/>

start=@<publication>

<publication> EXTRA :P31 {
 :P50 @<author> +;
}

<author> EXTRA :P31 {
 :P31 @<human> ;
 :P27 @<country_type> 
}

<country> EXTRA :P31 {
 :P31 @<country_type> 
}

<human> [ :Q174396 ]
<country_type> [ :Q183 ]
labra commented 3 years ago

In the previous ShEx definition, the <country> shape was not used, so the definition could be cleaned as:

PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
PREFIX :    <http://www.wikidata.org/entity/>

start=@<publication>

<publication> EXTRA :P31 {
 :P50 @<author> +;
}

<author> EXTRA :P31 {
 :P31 @<human> ;
 :P27 @<country_value> 
}

<human> [ :Q174396 ]  # Elf which means it shouldn't return results, could be replaced by Q5
<country_value> [ :Q183 ]
labra commented 3 years ago

In order to check the results that should be obtained, a SPARQL query for the previous ShEx could be https://w.wiki/4C6n which has no results

If we replace elfs by humans, it should be: https://w.wiki/4C6q which obtains 288651 results

labra commented 3 years ago

We have reproduced the problem in sparkwdsub and added a new issue