USGCRP / gcis-ontology

Ontology for the Global Change Information System
4 stars 7 forks source link

xsd:gYear in SPARQL #112

Closed justgo129 closed 9 years ago

justgo129 commented 9 years ago

Hi everyone, I notice that xsd:gYear isn't supported by SPARQL. See: http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#operandDataTypes

We do have instances of xsd:gYear in our turtle, e.g. when calling out publishing for publications, e.g. http://data.globalchange.gov/article/10.1289/ehp.8430.thtml (See 4th triple)

@zednis @xgmachina Please confirm that xsd:gYear isn't supported by SPARQL, and advise whether a different suffix is needed so as to facilitate SPARQL queries. Thanks.

(nb I need to change the template to read dbpprop:pubYear in-lieu of pubDate, but that's tangential)

zednis commented 9 years ago

@justgo129 Where does the link you provided say that gYear isn't supported in SPARQL?

Also, what is our desired usage of gYear in SPARQL? I suspect we can return and order publications by year just fine. Do we have a query that is attempting a filter by year that isn't working?

justgo129 commented 9 years ago

@zednis another link is: http://www.w3.org/TR/2013/REC-sparql11-query-20130321/#otherTermConstraints

While it doesn't say that xsd:gYear isn't supported by SPARQL, it's not included in the list of related xsd types that are.

We've mostly been using gYear for publication dates, similar to the above example.

zednis commented 9 years ago

Is there a specific operator you are concerned about? We will be able to retrieve and order by the publication years just fine. The only thing I can think of that ~might~ not work would be filter by year ranges, but even then I think it will work just fine.

Please attempt to find a SPARQL usage that is not working as intended.

justgo129 commented 9 years ago

Sure. The aim of this SPARQL query is to return the NCA3 findings based on material published after 2009. Not a great idea for a query clearly but it's a start.

Because the URL for the query within yasgui is so long, here is the SPARQL query: PREFIX rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns# PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema# PREFIX gcis: http://data.globalchange.gov/gcis.owl# PREFIX prov: http://www.w3.org/ns/prov# PREFIX cito: http://purl.org/spar/cito/ PREFIX dcterms: http://purl.org/dc/terms/ PREFIX dbpprop: http://dbpedia.org/property/ PREFIX xsd: http://www.w3.org/2001/XMLSchema# PREFIX http: http://www.w3.org/2011/http# SELECT distinct ?Finding from http://data.globalchange.gov WHERE { ?Finding a gcis:Finding . ?Finding cito:cites ?work . ?work dbpprop:pubDate ?year . FILTER (?year > xsd:gYear("2009")) }

which returns 137 entries.

Also, juxtaposing "?year" with "distinct ?Finding" results in the year's being output as: "2010-01-01T00:00:00-06:00"^^xsd:gYear which defeats the purpose of the xsd:gYear function on the penultimate line.

zednis commented 9 years ago

Is that number less than expected? I see 161 total findings in the report so that is 85% of the total findings.

justgo129 commented 9 years ago

Possibly less but it's in the ballpark. Why is the xsd:gYear suffix produced: "2010-01-01T00:00:00-06:00"^^xsd:gYear

in-lieu of simply "2010?" My understanding was that xsd:gYear serves as a function to strip the xsd output. Is it a function of a bad query (which I had adapted from another source which I don't recall), or an issue with attempting to perform a query on a triple with an xsd:gYear suffix to begin with?

zednis commented 9 years ago

It is probably an artifact from the endpoint implementation converting the xsd:gYear to a xsd:datetime to perform comparison operations. I do not expect all SPARQL endpoints to act the same.

Also I ran the following query to find all findings that have no cited work from after 2009 and I got 24 results, so I believe the 137 results from the earlier query is accurate.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX gcis: <http://data.globalchange.gov/gcis.owl#>
PREFIX cito: <http://purl.org/spar/cito/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dbpprop: <http://dbpedia.org/property/>
SELECT distinct ?Finding from <http://data.globalchange.gov>
WHERE {
  ?Finding a gcis:Finding
  FILTER NOT EXISTS { ?Finding cito:cites ?work . ?work dbpprop:pubDate ?year . FILTER (?year > xsd:gYear("2009")) }
}
justgo129 commented 9 years ago

Works for me. @bduggan or @rewolfe please feel free to close unless you'd like to continue discussing further.

justgo129 commented 9 years ago

Having seen no objection, I've closed #112.