sparna-git / Sparnatural

Sparnatural : visual knowledge graph explorer with SPARQL, in the browser, configurable with SHACL
http://sparnatural.eu
GNU Lesser General Public License v3.0
225 stars 41 forks source link

Ressurect begin date, end date, exact date variable fetching #645

Closed tfrancart closed 1 month ago

ch-sander commented 1 month ago

I had used begin date and end date variables successfully in SHACL:

g17sn:extended a sh:PropertyShape ;
    rdfs:label "extended"@en ;
    sparnatural:beginDateProperty "http://www.graceful17.org/ontology/started" ;
    sparnatural:endDateProperty "http://www.graceful17.org/ontology/ended" ;
    volipi:message "Extends over the time range for this date. (This is only a query pattern)" ;
    dash:searchWidget sparnatural:TimeProperty-Date ;
    sh:description "Extends over the time range for this date." ;
    sh:name "extended" ;
    sh:or ( [ sh:datatype xsd:date ;
                sh:nodeKind sh:Literal ] [ sh:node g17sn:date_value ;
                sh:nodeKind sh:Literal ] ) ;
    sh:path grace:extended .

It will create a correct query:

SELECT DISTINCT ?event_1 ?event_1_label WHERE {
  ?event_1 rdf:type <http://www.graceful17.org/ontology/event>;
    <http://www.graceful17.org/ontology/called> ?event_1_label;
    <http://www.graceful17.org/ontology/event_date> ?date_2.
  {
    ?date_2 <http://www.graceful17.org/ontology/started> ?date_2_begin;
      <http://www.graceful17.org/ontology/ended> ?date_2_end.
    FILTER(?date_2_begin <= "2030-01-01T22:59:59Z"^^xsd:dateTime)
    FILTER(?date_2_end >= "2019-02-04T23:00:00Z"^^xsd:dateTime)
  }
  UNION
  {
    ?date_2 <http://www.graceful17.org/ontology/started> ?date_2_end.
    FILTER(NOT EXISTS { ?date_2 <http://www.graceful17.org/ontology/ended> ?date_2_end. })
    FILTER(?date_2_begin <= "2030-01-01T22:59:59Z"^^xsd:dateTime)
  }
  UNION
  {
    ?date_2 <http://www.graceful17.org/ontology/ended> ?date_2_end.
    FILTER(NOT EXISTS { ?date_2 <http://www.graceful17.org/ontology/started> ?date_2_begin. })
    FILTER(?date_2_end >= "2019-02-04T23:00:00Z"^^xsd:dateTime)
  }
}
tfrancart commented 1 month ago

Thé query was missing the proper variables in the SELECT if you ever selected the date in the query editor

Thomas Francart -* SPARN*A linked data | domain ontologies | knowledge graphs blog : blog.sparna.fr, site : sparna.fr, linkedin : fr.linkedin.com/in/thomasfrancart tel : +33 (0)6.71.11.25.97

Le jeu. 17 oct. 2024 à 10:36, Christoph Sander @.***> a écrit :

I had used begin date and end date variables successfully in SHACL:

g17sn:extended a sh:PropertyShape ; rdfs:label @.*** ; sparnatural:beginDateProperty "http://www.graceful17.org/ontology/started" ; sparnatural:endDateProperty "http://www.graceful17.org/ontology/ended" ; volipi:message "Extends over the time range for this date. (This is only a query pattern)" ; dash:searchWidget sparnatural:TimeProperty-Date ; sh:description "Extends over the time range for this date." ; sh:name "extended" ; sh:or ( [ sh:datatype xsd:date ; sh:nodeKind sh:Literal ] [ sh:node g17sn:date_value ; sh:nodeKind sh:Literal ] ) ; sh:path grace:extended .

It will create a correct query:

SELECT DISTINCT ?event_1 ?event_1_label WHERE { ?event_1 rdf:type http://www.graceful17.org/ontology/event; http://www.graceful17.org/ontology/called ?event_1_label; http://www.graceful17.org/ontology/event_date ?date_2. { ?date_2 http://www.graceful17.org/ontology/started ?date_2_begin; http://www.graceful17.org/ontology/ended ?date_2_end. FILTER(?date_2_begin <= "2030-01-01T22:59:59Z"^^xsd:dateTime) FILTER(?date_2_end >= "2019-02-04T23:00:00Z"^^xsd:dateTime) } UNION { ?date_2 http://www.graceful17.org/ontology/started ?date_2_end. FILTER(NOT EXISTS { ?date_2 http://www.graceful17.org/ontology/ended ?date_2_end. }) FILTER(?date_2_begin <= "2030-01-01T22:59:59Z"^^xsd:dateTime) } UNION { ?date_2 http://www.graceful17.org/ontology/ended ?date_2_end. FILTER(NOT EXISTS { ?date_2 http://www.graceful17.org/ontology/started ?date_2_begin. }) FILTER(?date_2_end >= "2019-02-04T23:00:00Z"^^xsd:dateTime) } }

— Reply to this email directly, view it on GitHub https://github.com/sparna-git/Sparnatural/issues/645#issuecomment-2418912796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAU2H4IE6U2EWP4ZM526WWTZ35ZIDAVCNFSM6AAAAABP4P5SFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMJYHEYTENZZGY . You are receiving this because you modified the open/close state.Message ID: @.***>

ch-sander commented 1 month ago

Right!

ch-sander commented 1 week ago

my config:

g17sn:extended a sh:PropertyShape ;
    rdfs:label "extended"@en ;
    sparnatural:beginDateProperty "http://www.graceful17.org/ontology/started" ;
    sparnatural:endDateProperty "http://www.graceful17.org/ontology/ended" ;
    volipi:message "Extends over the time range for this date. (This is only a query pattern)" ;
    dash:searchWidget sparnatural:TimeProperty-Date ;
    sh:description "Extends over the time range for this date." ;
    sh:name "extended" ;
    sh:or ( [ sh:datatype xsd:date ;
                sh:nodeKind sh:Literal ] [ sh:datatype g17sn:date_value ;
                sh:node g17sn:date_value ;
                sh:nodeKind sh:Literal ] ) ;
    sh:path g17sn:extended ;
    sh:order 1.0 .

I don't quite understand why it won't work without some sh:path that is not rendered anyway being replaced by the sparnatural:xxxDateProperty construction. Is this intended or a collateral consequence of the parser?

tfrancart commented 1 week ago

I don't quite understand why it won't work without some sh:path that is not rendered anyway being replaced by the sparnatural:xxxDateProperty construction. Is this intended or a collateral consequence of the parser?

Because a PropertyShape requires a sh:path. This is mandatory in SHACL but I agree this value is not used in this situation.

ch-sander commented 1 week ago

Okay, good to know -- just wanted to make sure I'm not missing anything important. Thanks!