USGCRP / gcis-ontology

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

References (SPARQL query) #153

Closed justgo129 closed 8 years ago

justgo129 commented 8 years ago

I am preparing a SPARQL query for the unit test in order to encompass the turtle for "references." See e.g.: https://data.globalchange.gov/report/nca3/reference

The purpose of the following test is to count the number of articles cited in the NCA3 that came out after 2009, the date of the NCA2. Yes, I know some of the following lines are completely unnecessary but they are included for testing purposes.

prefix dcterms: <http://purl.org/dc/terms/>
prefix biro: <http://purl.org/spar/biro/>
prefix dbpprop: <http://dbpedia.org/property/>
prefix cito: <http://purl.org/spar/cito/>

select (count (?article) as ?Articles) from <http://data.globalchange.gov> where {
  ?s a biro:BibliographicRecord .
  ?s biro:references ?article .
  ?article a gcis:AcademicArticle .
  ?article cito:isCitedBy ?report .
  ?report dcterms:identifier "nca3" .
  ?article dbpprop:pubYear ?year .
  FILTER (?year > 2009) 
}

The result is: "0"^^xsd:integer. I'm a little confused as to why this should be the case. Taking one line at a time in order to debug, the issue seems to be with the FILTER line. My gut is because year is defined as xsd:gYear in-lieu of a number, as such filtering on a number would be difficult. I've tried various ways to get around this, none which work. Any advice?

Again, this is solely for increasing the scope of our unit tests; I'm not saying that one should write a SPARQL query which contains unnecessary lines.

zednis commented 8 years ago

try this:

prefix dcterms: <http://purl.org/dc/terms/>
prefix biro: <http://purl.org/spar/biro/>
prefix dbpprop: <http://dbpedia.org/property/>
prefix cito: <http://purl.org/spar/cito/>

select (count (?article) as ?Articles) from <http://data.globalchange.gov> where {
  ?s a biro:BibliographicRecord .
  ?s biro:references ?article .
  ?article a gcis:AcademicArticle .
  ?article cito:isCitedBy ?report .
  ?report dcterms:identifier "nca3" .
  ?article dbpprop:pubYear ?year .
  FILTER (?year > "2009"^^xsd:gYear) 
}

I get a result of 975.

zednis commented 8 years ago

@justgo129 where are you planning on putting this? This query as-is makes sense for gcis-sparql, but I do not think it makes sense to add it to the tests in gcis-ontology as it does not test any part of the gcis ontology, but is really just an example of how to query our instance data.

justgo129 commented 8 years ago

Yikes, dumb mistake on my apart. Thanks for catching it, @zednis. With regards to your question, I think it tests various terminology (e.g. "dbpprop:pubYear," etc.), potential future changes in which we'd like to flag. It's a good question though; let's chat about this during our next tagup.

zednis commented 8 years ago

@justgo129 If we want to test the RDF template to ensure that the instance data is being created in the desired manner than we should put this test in gcis (and it would be using test-only instance data); if we want to show an example of this query with the 975 results we should put the query in gcis-sparql. Since this query does not really utilize the GCIS ontology classes and properties I do not think it makes sense for this to be a test in gcis-ontology.

justgo129 commented 8 years ago

Closed #153 since it doesn't extensively utilize the GCIS ontology classes and properties.