0% found this document useful (0 votes)
321 views15 pages

Sparql Ld4pe 4

This document provides examples of using the SPARQL ASK query form to check various conditions on RDF data. It shows ASK queries over sample RDF data to check if: 1) All location values are URIs 2) All amount values are integers 3) The birthdates of Jurassic Park actors are dates 4) All birthdate values adhere to the xsd:date datatype 5) All birthplace values are URIs

Uploaded by

api-337446877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
321 views15 pages

Sparql Ld4pe 4

This document provides examples of using the SPARQL ASK query form to check various conditions on RDF data. It shows ASK queries over sample RDF data to check if: 1) All location values are URIs 2) All amount values are integers 3) The birthdates of Jurassic Park actors are dates 4) All birthdate values adhere to the xsd:date datatype 5) All birthplace values are URIs

Uploaded by

api-337446877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

68

USING SPARQL ASK

69

ASK Example: RDF Data


@prefix dm: <http://ld4pe.org/ns/demo#> .
@prefix d: <http://ld4pe.org/ns/data#> .
d:item432 dm:cost 8.50 ;
dm:amount 14 ;
dm:approval d:emp079 ;
dm:location <http://DBpedia.org/resource/Boston> .
d:item201 dm:cost 9.25 ;
dm:amount 12 ;
dm:approval d:emp092 ;
dm:location <http://DBpedia.org/resource/Ghent> .
d:item857 dm:cost 12 ;
dm:amount 10 ;
dm:location <http://DBpedia.org/resource/Montreal> .
d:item693 dm:cost 10.25 ;
dm:amount 1.5 ;
dm:location "Heidelberg" .
d:item126 dm:cost 5.05 ;
dm:amount 4 ;
dm:location <http://DBpedia.org/resource/Lisbon> .
d:emp092 dm:jobGrade 1 .
d:emp041 dm:jobGrade 3 .
d:emp079 dm:jobGrade 5 .

70

ASK EXAMPLE (1)


Check values of dm:location property to see whether
or not they are all URIs.

71

ASK EXAMPLE (1)


Query:
PREFIX dm: <http://ld4pe.org/ns/demo#>
ASK WHERE
{
?s dm:location ?city .
FILTER (!(isURI(?city)))
}

Result:
ASK
Yes

72

ASK EXAMPLE (2)


Check values of dm:amount property to see whether or not
they are all integers.
* Consider using datatype & xsd:integer

73

ASK EXAMPLE (2)


Query:
PREFIX dm: <http://ld4pe.org/ns/demo#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
ASK WHERE
{
?item dm:amount ?amount .
FILTER ((datatype(?amount)) != xsd:integer)
}
Result:
ASK
Yes

74

ASK QUIZZES
DBpedia SPARQL Endpoint

75

Quiz (1)
Check datatype for instances of foaf:Person to see whether or

not the values are URIs.

76

Answer (1)
ASK WHERE
{
?i a foaf:Person.
FILTER ((isURI(?i)))
}

77

Quiz (2)
Check datatype for whether or not the birthdates of the actors

starring in Jurassic Park are all dates.

78

Answer (2)
ASK WHERE
{
<http://DBpedia.org/resource/Jurassic_Park> dbo:starring ?
actor.
?actor dbo:birthDate ?birthdate.
FILTER ((datatype(?birthdate))=xsd:date)
}

79

Quiz (3)
Check datatype see whether or not all of the dbo:birthDate

values adhere to xsd:date.

80

Answer (3)
ask
where {
?s dbo:birthDate ?date.
filter (datatype(?date) != xsd:date)
}

81

Quiz (4)
Check datatype to see whether or not all of the dbo:birthPlace

values are URIs.

82

Answer (4)
ASK WHERE
{
?i dbo:birthPlace ?Place.
FILTER(!(isURI(?Place)))
}

You might also like