[SOLVED] LIMIT 50

$25

File Name: LIMIT_50.zip
File Size: 75.36 KB

5/5 - (1 vote)

RDF & SPARQL (Contd.)

Copyright By Assignmentchef assignmentchef

The slides are prepared by Dr.

Lecture Outline
Programming the semantic Web
Working with RDF documents in Apache Jena
SPARQL queries in Jena
Remote data and local query processor
SPARQL endpoint
Understanding the semantic of SPARQL queries
Movie example

Programming the Semantic Web

https://rdf4j.org/documentation/programming/

Apache Jena
Architecture

https://jena.apache.org/getting_started/index.html

Getting Started

Maven Dependencies

Copyright (Jena Examples)

Working with RDF Documents in Jena

A Semantic Web Primer

A Simple RDF Model

Resources as Property Values

Resources as Property Values

Attribute Accessor Methods

Write RDF/XML into File

Read RDF XML from a File

Navigating a Model

Selecting the VCARD Resources

Selector Methods

Graph Operations

Graph Operations

Containers

[ 11^^ , 11 ] .

[ , ] .

SPARQL Queries in Jena

SPARQL Queries

SPARQL Queries
Select (local)

SPARQL Queries
Select (remote)

SPARQL Queries
Construct (local)

SPARQL Queries
Ask (local)

SPARQL Queries
Describe (local)

Take a break

Remote Data &
Local Query Processor

Data is accessed via URI
Query is processed using Jena

SPARQL Queries
Remote Data & Local Query Processor
http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf
PREFIX foaf:
SELECT * WHERE {
?s foaf:name ?name . FILTER regex (?name,^A , i)
} limit 50

Write a query that finds the names that start with either A or B and end with C.

SPARQL Queries
Remote Data & Local Query Processor
http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf
PREFIX foaf:
PREFIX card:
SELECT ?homepage
card:i foaf:knows ?known .
?known foaf:homepage ?homepage .

Query is processed at the Endpoint
SPARQL Endpoint

SPARQL Queries
SPARQL Endpoint
http://dbpedia.org/sparql
PREFIX owl:
PREFIX xsd:
PREFIX rdfs:
PREFIX rdf:
PREFIX foaf:
PREFIX dc:
PREFIX :
PREFIX dbpedia2:
PREFIX dbpedia:
PREFIX skos:
PREFIX dbo:

SPARQL Queries
SPARQL Endpoint
People who were born in Sydney before 1985
SELECT ?name ?birth ?death ?person
?person dbo:birthPlace :Sydney .
?person dbo:birthDate ?birth .
?person foaf:name ?name .
?person dbo:deathDate ?death .
FILTER (?birth < 1985-01-01″^^xsd:date) . }ORDER BY ?name LIMIT 50SPARQL QueriesSPARQL EndpointMusicians with German and English descriptions.SELECT ?name ?description_en ?description_de ?musician ?musician foaf:name ?name . ?musician a dbo:MusicalArtist .OPTIONAL { ?musician rdfs:comment ?description_en . FILTER (LANG(?description_en) = ‘en’) . } OPTIONAL { ?musician rdfs:comment ?description_de . FILTER (LANG(?description_de) = ‘de’) . }} LIMIT 50SPARQL QueriesSPARQL EndpointMusicians who were born in Berlin. SELECT ?name ?birth ?description ?person WHERE {?person a dbo:MusicalArtist .?person dbo:birthPlace :Berlin .?person dbo:birthDate ?birth .?person foaf:name ?name .?person rdfs:comment ?description .FILTER (LANG(?description) = ‘en’) . } ORDER BY ?name LIMIT 50SPARQL QueriesSPARQL EndpointSoccer players who are born in a country with more than 10 million inhabitants, who played as goalkeeper for a club that has a stadium with more than 30,000 seats and the club country is different from the birth country.SELECT distinct ?soccerplayer ?countryOfBirth ?team ?countryOfTeam ?stadiumcapacity ?soccerplayer a dbo:SoccerPlayer ; dbo:position ;
dbo:birthPlace/dbo:country* ?countryOfBirth ;
#dbo:number 13 ;
dbo:team ?team .
?team dbo:capacity ?stadiumcapacity ; dbo:ground ?countryOfTeam .
?countryOfBirth a dbo:Country ; dbo:populationTotal ?population .
?countryOfTeam a dbo:Country .
FILTER (?countryOfTeam != ?countryOfBirth)
FILTER (?stadiumcapacity > 30000)
FILTER (?population > 10000000)
} order by ?soccerplayer

Understanding the Semantic of SPARQL Queries

SPARQL Queries
Query Semantic
PREFIX foaf:PREFIX res:
SELECT DISTINCT ?string WHERE { res:Tom_Cruise foaf:homepage ?string . }

SPARQL Queries
Query Semantic
PREFIX dbo:
PREFIX res:
PREFIX rdf:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE {
?uri rdf:type dbo:Film . ?uri dbo:starring res:Julia_Roberts . ?uri dbo:starring res:Richard_Gere. OPTIONAL {?uri rdfs:label ?string . FILTER (lang(?string) = en) }
} LIMIT 50

SPARQL Queries
Query Semantic
PREFIX dbo:
PREFIX res:
PREFIX rdf:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE {
?uri rdf:type dbo:Book . ?uri dbo:author res:Danielle_Steel .
OPTIONAL { ?uri rdfs:label ?string . FILTER (lang(?string) = en) }
} LIMIT 50

SPARQL Queries
Query Semantic
PREFIX res:
PREFIX dbp:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE {
res:WikiLeaks dbp:awards ?uri .
OPTIONAL { ?uri rdfs:label ?string. FILTER (lang(?string) = en) }
} LIMIT 50

SPARQL Queries
Query Semantic
PREFIX dbo:
PREFIX res:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE {
res:Nile dbo:sourceCountry ?uri . OPTIONAL {
?uri rdfs:label ?string. FILTER (lang(?string) = en) }
} LIMIT 50

SPARQL Queries
Query Semantic
PREFIX dbp:
PREFIX dbo:
PREFIX res:
PREFIX rdf:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE {
?uri rdf:type dbo:Company . ?uri dbp:industry ?industry . FILTER regex(?industry,advertising,i) . OPTIONAL {?uri rdfs:label ?string . FILTER (lang(?string) = en) }
} LIMIT 50

SPARQL Queries
Query Semantic
PREFIX res:
PREFIX dbo:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE { res:Bruce_Carver dbo:deathCause ?uri . OPTIONAL {?uri rdfs:label ?string. FILTER (lang(?string) = en) }
} LIMIT 50

SPARQL Queries
Query Semantic
PREFIX dbo:
PREFIX res:
PREFIX rdf:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE {
?uri rdf:type dbo:Airport . ?uri dbo:location res:California .
OPTIONAL { ?uri rdfs:label ?string . FILTER (lang(?string) = en) }
} LIMIT 50

SPARQL Queries
Query Semantic
PREFIX dbo:
PREFIX res:
PREFIX rdf:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE {
?uri rdf:type dbo:Film. ?uri dbo:starring res:Tom_Cruise .
OPTIONAL {?uri rdfs:label ?string . FILTER (lang(?string) = en) }
} LIMIT 50

SPARQL Queries
Query Semantic
PREFIX dbo:
PREFIX res:
PREFIX rdf:
PREFIX rdfs:
SELECT DISTINCT ?uri ?string WHERE {
?company rdf:type dbo:Organisation .
?company dbo:foundationPlace res:California .
?uri dbo:developer ?company .
?uri rdf:type dbo:Software . OPTIONAL { ?uri rdfs:label ?string . FILTER (lang(?string) = en) } } LIMIT 50

SPARQL Queries
Query Semantic
PREFIX dbo:
PREFIX res:
PREFIX rdf:
PREFIX rdfs:
SELECT COUNT(DISTINCT ?uri) WHERE {
?uri rdf:type dbo:Film .
?uri dbo:starring res:Leonardo_DiCaprio .
} LIMIT 50

Movies Example

Movies Example

Movies Example

Movies Example
SPARQL Query
BASE
PREFIX xs:
SELECT DISTINCT ?p{
?s ?p ?o .

Movies Example
SPARQL Query
BASE
PREFIX xs:
SELECT ?m ?c WHERE {
?m ?c FILTER (?c = Australia).

Movies Example
SPARQL Query
BASE
PREFIX xs:
SELECT(COUNT(?c) as ?ct) WHERE{
?movie ?c .
?movie ?g FILTER regex(?g,Horror).
} GROUP BY ?c

Movies Example
SPARQL Query
BASE
PREFIX xs:
SELECT * {
?m ?score .
} ORDER BY DESC(?score) OFFSET 0 LIMIT 5

Movies Example
SPARQL Query
BASE
PREFIX xs:
SELECT ?c (AVG(xs:integer(?s)) as ?av) WHERE {
?m ?s .
?m ?c .
} GROUP BY (?c)

Movies Example
SPARQL Query
BASE
PREFIX xs:
SELECT ?c (SUM(xs:float(?d)) as ?total) WHERE {
?m ?d .
?m ?c .
} GROUP BY (?c)

http://www.w3.org/TR/rdf-sparql-query/
https://jena.apache.org/
https://aifb-ls3-kos.aifb.kit.edu/projects/spartiqulator/examples.htm
Chapter 3 of Semantic Web Primer

/docProps/thumbnail.jpeg

CS: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] LIMIT 50
$25