Project:SPARQL/examples: Difference between revisions

From Beyond Notability
Line 2,707: Line 2,707:


<sparql tryit="1">
<sparql tryit="1">
# union query to get [hopefully] every date associated with women FSAs including main dates and qualifier dates and date precision
# fishing for dates for FSAs
# union query to get [hopefully] every date associated with women FSAs including main dates and qualifier dates, with date precision


PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
PREFIX bnwd: <https://beyond-notability.wikibase.cloud/entity/>
Line 2,719: Line 2,720:
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>
PREFIX bnpqv: <https://beyond-notability.wikibase.cloud/prop/qualifier/value/>


SELECT distinct ?person ?personLabel ?date_prop_label ?date_value ?date_precision ?qual ?qualLabel ?date_prop_type
SELECT distinct ?person ?personLabel ?date_prop_label ?date_value ?date_precision ?pdv ?pdvLabel  
#?s  #statement url [for grouping]
#?s  ?date_prop  ?date_prop_type
#?date_prop  #property url/id


WHERE {
WHERE {
Line 2,764: Line 2,764:
         wikibase:statementProperty ?ps.     
         wikibase:statementProperty ?ps.     
       ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en-gb") .  
       ?prop rdfs:label ?prop_label. filter(lang(?prop_label)="en-gb") .  
      # get stuff about ?s.
      ?s ?ps ?qual.
    
    
        # get stuff about qual if you want
      # get stuff about ?p via ps. .
        # optional { 
      # pdv was called ?qual but it isn't a qual; it's the direct value (usually item) for the property, things like annual meeting, girton college. .
        # what sort of thing is qual
      ?s ?ps ?pdv.
        #  ?qual bnwdt:P12 ?inst . # instance of can be multiple so could get some dups
        #} # /qual optional
 
    
    
       # get qualifier dates [are there any Edtf in qualifier dates?]  
       # get qualifier dates . ?pq is the date property like P1 .
       ?s ?pq ?pqs .
       ?s ?pq ?pqs .  
     
        # get pq and restrict to dates here, instead of using a filter.
      # this needs to be limited to dates... I think
         ?qual_prop wikibase:qualifier ?pq
      FILTER(DATATYPE(?pqs) = xsd:dateTime).
        ?qual_prop wikibase:propertyType wikibase:Time.  
 
         ?qual_prop rdfs:label ?date_prop_label . filter(lang(?date_prop_label)="en") .
    ## to check for edtf dates
    ## docs: https://github.com/ProfessionalWiki/WikibaseEdtf     
    ## i think it should be just a matter of changing the datatype filter to xsd:edtf
    ## and remove dates detail lines below
    ## 0 results which is *probably* correct so not adding it at present.
    ##  FILTER(DATATYPE(?pqs) = xsd:edtf).
 
        # get stuff about pq
         ?qual_prop wikibase:qualifier ?pq;     
            wikibase:propertyType ?date_prop_type.  
         ?qual_prop rdfs:label ?date_prop_label . filter(lang(?date_prop_label)="en-gb") . # what sort of date is it.
    
    
       # get dates detail. TODO: how to get the /entity/ url for date_prop?
       # now get detail.  
       ?s ?date_prop ?pqv .
       ?s ?date_prop ?pqv .
         ?pqv wikibase:timeValue ?date_value.
         ?pqv wikibase:timeValue ?date_value.
         ?pqv wikibase:timePrecision ?date_precision.
         ?pqv wikibase:timePrecision ?date_precision.
   
       
   }  # /qual dates
   }  # /qual dates
    
    
614

edits