SlideShare a Scribd company logo
1 of 23
Download to read offline
Developing for the
Semantic Web
by Timea Turdean
21.11.2015
#devfest15
Vienna
SEMANTIC WEB
&
LINKED DATA
2 http://dbpedia.org/resource/Sir_Tim_Berners_Lee
Triple
http://example.org/myProject/Triple
the form of
subject–predicate–object
expressions
<?s ?p ?o>
World Wide Web Consortium
(w3.org)
English computer scientists
RDF
http://dbpedia.org/resource/Resource_Description_Framework
http://www.w3.
org/2004/02/skos/core#de
finition
http://www.w3.org/1999/02/22-rdf-
syntax-ns#type http://example.org/Timea-
Custom-
Scheme/contained_in
http://example.org/Timea-
Custom-
Scheme/knows_to_use
3
Place your screenshot here
4Web
Application
http://preview.poolparty.biz/sparqlingCocktails/cocktails
5FEATURES &
FUNCTIONALITY
● Tap into your Linked Data endpoint
● Query Linked Data
● Display your Linked Data
● Display OPEN Linked Data
● The power of Linked Data
● BONUS *An improved search
Tap into your
Linked Data
endpoint
▸ data contains:
6 ▸ data is available
through a
SPARQL
endpoint
Tap into your
Linked Data
endpoint
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.
org/2004/02/skos/core#Concept> .
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/2004/02/skos/core#prefLabel> "Brandy"@en .
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/2004/02/skos/core#altLabel> "Grape spirit"@en .
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/2004/02/skos/core#definition> "Brandy (from brandywine, derived from
Dutch brandewijnu2014"burnt wine") is a spirit produced by distilling wine. Brandy
generally contains 35u201360% alcohol by volume and is typically taken as an after-
dinner drink. Some brandies are aged in wooden casks, some are coloured with caramel
colouring to imitate the effect of aging, and some brandies are produced using a
combination of both aging and colouring."@en .
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/2004/02/skos/core#narrower> <http://vocabulary.semantic-web.
at/cocktails/16b625c5-3930-4cf8-a75b-b25e72f2bfb6> .
<http://vocabulary.semantic-web.at/cocktails/16b625c5-3930-4cf8-a75b-b25e72f2bfb6>
<http://www.w3.org/2004/02/skos/core#prefLabel> "Calvados"@en .
7
SPARQL
8 SELECT * WHERE
{
?s ?p ?o
}
SELECT * WHERE
{
?s ?p ?o
}
Query
Linked Data
▸ Give me all Alcoholic Beverages:
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
SELECT ?label WHERE {
<http://vocabulary.semantic-web.
at/cocktails/f3000285-36b0-4ffe-af90-
740c2dd8fff5> skos:narrower ?o .
?o skos:prefLabel ?label .
}
▸ Results:
"Brandy"@en
"Fortified wine"@en
"Gin"@en
"Liqueur"@en
"Rum"@en
"Schnapps"@en
"Tequila"@en
"Vodka"@en
"Whisky"@en
"Wine"@en
9
Tap into your
Linked Data
endpoint
public class SPARQLendpointConnection extends HttpClient {
URL sparqlEndpointURL = null;
NameValuePair queryParam = new NameValuePair( "query", "QUERY");
List<NameValuePair> urlParams = new ArrayList() ;
List<Header> headers = new ArrayList<>() ;
public SPARQLendpointConnection (URL sparqlEndpointURL) {
this.sparqlEndpointURL = sparqlEndpointURL ;
this.addQueryParameter( "query", "QUERY");
this .addQueryParameter( "content-type" , "application/json" );
super .getParams().setParameter( "http.protocol.version" , HttpVersion. HTTP_1_1);
super .getParams().setParameter( "http.protocol.content-charset" , "UTF-8");
}
public void addQueryParameter (String key , String value) {
if (value.equals( "QUERY")) {
this.queryParam = new NameValuePair(key , value);
} else {
this.urlParams.add(new NameValuePair(key , value));
}
} [...]
}
10
Display your
Linked Data
public class SPARQLendpointConnection extends HttpClient {
public TupleQueryResult runAndParseSelectQuery (String query) throws IOException {
InputStream in = null;
TupleQueryResult tqr = null;
try {
in = IOUtils. toInputStream(runSelectQuery(query)) ;
tqr = QueryResultIO. parse(in, TupleQueryResultFormat. JSON);
return tqr;
} catch (QueryResultParseException | TupleQueryResultHandlerException |
UnsupportedQueryResultFormatException ex) {
throw new IOException(ex) ;
} finally {
if (in != null) {
in.close() ;
}
}
}
}
11
Display your
Linked Data
public class SPARQLendpointConnection extends HttpClient {
public String runSelectQuery (String query) throws IOException {
PostMethod post = new PostMethod( this.sparqlEndpointURL .toString()) ;
NameValuePair[] params = this.urlParams.toArray(new NameValuePair[ this.urlParams.
size() + 1]);
params[(params. length - 1)] = new NameValuePair( queryParam .getName() , query);
post.setRequestBody(params) ;
for (Header h : this.headers) { post.addRequestHeader(h) ; }
int statusCode ;
String response ;
try {
statusCode = super.executeMethod(post) ;
response = post.getResponseBodyAsString() ;
if (statusCode != HttpStatus. SC_OK) {
System. out.println(statusCode) ;
}} finally {
post.releaseConnection() ;
}
return response;
}}
12
Tap into your
Linked Data
endpoint
import org.apache.commons.httpclient.* ;
import org.apache.commons.httpclient.methods.PostMethod ;
13
org.apache.commons.httpclient.jar
commons.io.jar
import org.apache.commons.io.IOUtils ;
sesame-query.jar
import org.openrdf.query.TupleQueryResult ;
import org.openrdf.query.TupleQueryResultHandlerException ;
sesame-queryresultio-api.jar; sesame-queryresultio-sparqljson.jar
import org.openrdf.query.resultio.QueryResultIO ;
import org.openrdf.query.resultio.QueryResultParseException ;
import org.openrdf.query.resultio.TupleQueryResultFormat ;
import org.openrdf.query.resultio.UnsupportedQueryResultFormatException ;
Display your
Linked Data
public void test() throws Exception {
String value = "";
SPARQLendpointConnection myConncetion = new SPARQLendpointConnection( new URL("http:
//vocabulary.semantic-web.at/PoolParty/sparql/cocktails" ));
TupleQueryResult tqr = myConnection.runAndParseSelectQuery(
"PREFIX skos:<http://www.w3.org/2004/02/skos/core#> n" +
"SELECT ?label WHERE { n" +
"<http://vocabulary.semantic-web.at/cocktails/f3000285-36b0-4ffe-af90-740c2dd8fff5>
skos:narrower ?p . n" +
"?p skos:prefLabel ?label n" +
"}");
BindingSet bs = null;
try {
while (tqr.hasNext()) {
bs = tqr.next() ;
value = bs.getValue( "label").toString() ;
System.out.println(bs.getValue( "label"));
}} finally {
tqr.close() ;
}}
14
Display your
Linked Data
"Brandy"@en
"Fortified wine"@en
"Gin"@en
"Liqueur"@en
"Rum"@en
"Schnapps"@en
"Tequila"@en
"Vodka"@en
"Whisky"@en
"Wine"@en
15 RESULTS
Display your
Linked Data
private ModelAndView mavChooseIngredients;
mavChooseIngredients = new ModelAndView( "cocktails/index" );
mavChooseIngredients .addObject( "myMenu", this.retrieveMainAlcoholicBeverages()) ;
[..]
public List<BindingSet> retrieveMainAlcoholicBeverages () throws
IOException , QueryEvaluationException {
return QueryResults. asList(myConnection .runAndParseSelectQuery(
"PREFIX skos:<http://www.w3.org/2004/02/skos/core#> n" +
"SELECT ?label WHERE { n" +
"<http://vocabulary.semantic-web.at/cocktails/f3000285-36b0-4ffe-af90-
740c2dd8fff5> skos:narrower ?p . n" +
"?p skos:prefLabel ?label n" +
"}"
));
}
16
Display your
Linked Data
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core " %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions " %>
[...]
<c:forEach items="${myMenu}" var="bindingSet ">
<li class="entity">
${bindingSet.getValue( 'label').stringValue() }
</li>
</c:forEach>
17 index.jsp
Display OPEN
Linked Data
DBpedia SPARQL endpoint:
▸ http://dbpedia.org/sparql
SELECT * WHERE {
<http://dbpedia.org/resource/Negroni>
<http://dbpedia.org/ontology/abstract>
?abstract
}
18
The POWER
of
Linked data
▸ easy change of data
▸ cost efficient
▸ graph algorithms
19
Place your screenshot here
20An improved SEARCH
Faceted search
http://preview.poolparty.biz/sparqlingCocktails/search
Thank you!
21
Connect
Timea Turdean
Technical Consultant, Semantic Web Company
▸ timea.turdean@gmail.com
▸ http://at.linkedin.com/in/timeaturdean
▸ http://timeaturdean.com
22
© Semantic Web Company - http://www.semantic-web.at/ and http://www.poolparty.biz/
▸ LD2014 picture slide3- http://data.dws.informatik.uni-
mannheim.de/lodcloud/2014/
▸ Linked Data principles: http://www.w3.
org/DesignIssues/LinkedData.html
▸ Introduction to Semantic Web: http://timeaturdean.
com/introduction-semantic-web/
23Resources

More Related Content

What's hot

Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...Red Hat Developers
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Andres Almiray
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Andres Almiray
 
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
FluentLeniumで困った話
FluentLeniumで困った話FluentLeniumで困った話
FluentLeniumで困った話Yuuki Ooguro
 
Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv IT Booze
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyAlessandro Cucci
 
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
How to cheat jb detector and detect cheating
How to cheat jb detector and detect cheatingHow to cheat jb detector and detect cheating
How to cheat jb detector and detect cheatingHokila Jan
 
Test Driven Documentation with Spring Rest Docs
Test Driven Documentation with Spring Rest DocsTest Driven Documentation with Spring Rest Docs
Test Driven Documentation with Spring Rest DocsRoman Tsypuk
 
Functional tests with TYPO3
Functional tests with TYPO3Functional tests with TYPO3
Functional tests with TYPO3cpsitgmbh
 
Hypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTHypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTSofiia Vynnytska
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8WindowsPhoneRocks
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIRPeter Elst
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long jaxconf
 
Taking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingTaking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingJulien Pivotto
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to TestZsolt Fabok
 

What's hot (20)

Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
 
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
 
VRaptor 4 - JavaOne
VRaptor 4 - JavaOneVRaptor 4 - JavaOne
VRaptor 4 - JavaOne
 
AssertJ quick introduction
AssertJ quick introductionAssertJ quick introduction
AssertJ quick introduction
 
FluentLeniumで困った話
FluentLeniumで困った話FluentLeniumで困った話
FluentLeniumで困った話
 
Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemy
 
9.Spring DI_4
9.Spring DI_49.Spring DI_4
9.Spring DI_4
 
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
How to cheat jb detector and detect cheating
How to cheat jb detector and detect cheatingHow to cheat jb detector and detect cheating
How to cheat jb detector and detect cheating
 
Test Driven Documentation with Spring Rest Docs
Test Driven Documentation with Spring Rest DocsTest Driven Documentation with Spring Rest Docs
Test Driven Documentation with Spring Rest Docs
 
Functional tests with TYPO3
Functional tests with TYPO3Functional tests with TYPO3
Functional tests with TYPO3
 
Hypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTHypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data REST
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long
 
Taking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingTaking advantage of Prometheus relabeling
Taking advantage of Prometheus relabeling
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
 

Viewers also liked

Intro to Semantic Web
Intro to Semantic WebIntro to Semantic Web
Intro to Semantic WebTimea Turdean
 
Overcoming impostor syndrome
Overcoming impostor syndromeOvercoming impostor syndrome
Overcoming impostor syndromeTimea Turdean
 
RDF Analytics... SPARQL and Beyond
RDF Analytics... SPARQL and BeyondRDF Analytics... SPARQL and Beyond
RDF Analytics... SPARQL and BeyondFadi Maali
 
Self-service Linked Government Data
Self-service Linked Government DataSelf-service Linked Government Data
Self-service Linked Government DataFadi Maali
 
Estimating value through the lens of cost of delay
Estimating value through the lens of cost of delayEstimating value through the lens of cost of delay
Estimating value through the lens of cost of delayagilebydesign
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Springsdeeg
 

Viewers also liked (7)

Intro to Semantic Web
Intro to Semantic WebIntro to Semantic Web
Intro to Semantic Web
 
Intro to AngularJS
Intro to AngularJSIntro to AngularJS
Intro to AngularJS
 
Overcoming impostor syndrome
Overcoming impostor syndromeOvercoming impostor syndrome
Overcoming impostor syndrome
 
RDF Analytics... SPARQL and Beyond
RDF Analytics... SPARQL and BeyondRDF Analytics... SPARQL and Beyond
RDF Analytics... SPARQL and Beyond
 
Self-service Linked Government Data
Self-service Linked Government DataSelf-service Linked Government Data
Self-service Linked Government Data
 
Estimating value through the lens of cost of delay
Estimating value through the lens of cost of delayEstimating value through the lens of cost of delay
Estimating value through the lens of cost of delay
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Spring
 

Similar to SPARQLing cocktails

WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaKatrien Verbert
 
03 form-data
03 form-data03 form-data
03 form-datasnopteck
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
SWT Lecture Session 4 - SW architectures and SPARQL
SWT Lecture Session 4 - SW architectures and SPARQLSWT Lecture Session 4 - SW architectures and SPARQL
SWT Lecture Session 4 - SW architectures and SPARQLMariano Rodriguez-Muro
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
China Science Challenge
China Science ChallengeChina Science Challenge
China Science Challengeremko caprio
 
SgCodeJam24 Workshop
SgCodeJam24 WorkshopSgCodeJam24 Workshop
SgCodeJam24 Workshopremko caprio
 
JavaScript straight from the Oracle Database
JavaScript straight from the Oracle DatabaseJavaScript straight from the Oracle Database
JavaScript straight from the Oracle DatabaseDimitri Gielis
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!DataArt
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Claire Townend Gee
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginsearchbox-com
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scalarostislav
 
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話Takehito Tanabe
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web developmentJohannes Brodwall
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 

Similar to SPARQLing cocktails (20)

WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPedia
 
03 form-data
03 form-data03 form-data
03 form-data
 
4 sw architectures and sparql
4 sw architectures and sparql4 sw architectures and sparql
4 sw architectures and sparql
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
URLProtocol
URLProtocolURLProtocol
URLProtocol
 
SWT Lecture Session 4 - SW architectures and SPARQL
SWT Lecture Session 4 - SW architectures and SPARQLSWT Lecture Session 4 - SW architectures and SPARQL
SWT Lecture Session 4 - SW architectures and SPARQL
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
China Science Challenge
China Science ChallengeChina Science Challenge
China Science Challenge
 
SgCodeJam24 Workshop
SgCodeJam24 WorkshopSgCodeJam24 Workshop
SgCodeJam24 Workshop
 
JavaScript straight from the Oracle Database
JavaScript straight from the Oracle DatabaseJavaScript straight from the Oracle Database
JavaScript straight from the Oracle Database
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component plugin
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scala
 
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 

Recently uploaded

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 

Recently uploaded (20)

What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

SPARQLing cocktails

  • 1. Developing for the Semantic Web by Timea Turdean 21.11.2015 #devfest15 Vienna
  • 2. SEMANTIC WEB & LINKED DATA 2 http://dbpedia.org/resource/Sir_Tim_Berners_Lee Triple http://example.org/myProject/Triple the form of subject–predicate–object expressions <?s ?p ?o> World Wide Web Consortium (w3.org) English computer scientists RDF http://dbpedia.org/resource/Resource_Description_Framework http://www.w3. org/2004/02/skos/core#de finition http://www.w3.org/1999/02/22-rdf- syntax-ns#type http://example.org/Timea- Custom- Scheme/contained_in http://example.org/Timea- Custom- Scheme/knows_to_use
  • 3. 3
  • 4. Place your screenshot here 4Web Application http://preview.poolparty.biz/sparqlingCocktails/cocktails
  • 5. 5FEATURES & FUNCTIONALITY ● Tap into your Linked Data endpoint ● Query Linked Data ● Display your Linked Data ● Display OPEN Linked Data ● The power of Linked Data ● BONUS *An improved search
  • 6. Tap into your Linked Data endpoint ▸ data contains: 6 ▸ data is available through a SPARQL endpoint
  • 7. Tap into your Linked Data endpoint <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3. org/2004/02/skos/core#Concept> . <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/2004/02/skos/core#prefLabel> "Brandy"@en . <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/2004/02/skos/core#altLabel> "Grape spirit"@en . <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/2004/02/skos/core#definition> "Brandy (from brandywine, derived from Dutch brandewijnu2014"burnt wine") is a spirit produced by distilling wine. Brandy generally contains 35u201360% alcohol by volume and is typically taken as an after- dinner drink. Some brandies are aged in wooden casks, some are coloured with caramel colouring to imitate the effect of aging, and some brandies are produced using a combination of both aging and colouring."@en . <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/2004/02/skos/core#narrower> <http://vocabulary.semantic-web. at/cocktails/16b625c5-3930-4cf8-a75b-b25e72f2bfb6> . <http://vocabulary.semantic-web.at/cocktails/16b625c5-3930-4cf8-a75b-b25e72f2bfb6> <http://www.w3.org/2004/02/skos/core#prefLabel> "Calvados"@en . 7
  • 8. SPARQL 8 SELECT * WHERE { ?s ?p ?o } SELECT * WHERE { ?s ?p ?o }
  • 9. Query Linked Data ▸ Give me all Alcoholic Beverages: PREFIX skos:<http://www.w3.org/2004/02/skos/core#> SELECT ?label WHERE { <http://vocabulary.semantic-web. at/cocktails/f3000285-36b0-4ffe-af90- 740c2dd8fff5> skos:narrower ?o . ?o skos:prefLabel ?label . } ▸ Results: "Brandy"@en "Fortified wine"@en "Gin"@en "Liqueur"@en "Rum"@en "Schnapps"@en "Tequila"@en "Vodka"@en "Whisky"@en "Wine"@en 9
  • 10. Tap into your Linked Data endpoint public class SPARQLendpointConnection extends HttpClient { URL sparqlEndpointURL = null; NameValuePair queryParam = new NameValuePair( "query", "QUERY"); List<NameValuePair> urlParams = new ArrayList() ; List<Header> headers = new ArrayList<>() ; public SPARQLendpointConnection (URL sparqlEndpointURL) { this.sparqlEndpointURL = sparqlEndpointURL ; this.addQueryParameter( "query", "QUERY"); this .addQueryParameter( "content-type" , "application/json" ); super .getParams().setParameter( "http.protocol.version" , HttpVersion. HTTP_1_1); super .getParams().setParameter( "http.protocol.content-charset" , "UTF-8"); } public void addQueryParameter (String key , String value) { if (value.equals( "QUERY")) { this.queryParam = new NameValuePair(key , value); } else { this.urlParams.add(new NameValuePair(key , value)); } } [...] } 10
  • 11. Display your Linked Data public class SPARQLendpointConnection extends HttpClient { public TupleQueryResult runAndParseSelectQuery (String query) throws IOException { InputStream in = null; TupleQueryResult tqr = null; try { in = IOUtils. toInputStream(runSelectQuery(query)) ; tqr = QueryResultIO. parse(in, TupleQueryResultFormat. JSON); return tqr; } catch (QueryResultParseException | TupleQueryResultHandlerException | UnsupportedQueryResultFormatException ex) { throw new IOException(ex) ; } finally { if (in != null) { in.close() ; } } } } 11
  • 12. Display your Linked Data public class SPARQLendpointConnection extends HttpClient { public String runSelectQuery (String query) throws IOException { PostMethod post = new PostMethod( this.sparqlEndpointURL .toString()) ; NameValuePair[] params = this.urlParams.toArray(new NameValuePair[ this.urlParams. size() + 1]); params[(params. length - 1)] = new NameValuePair( queryParam .getName() , query); post.setRequestBody(params) ; for (Header h : this.headers) { post.addRequestHeader(h) ; } int statusCode ; String response ; try { statusCode = super.executeMethod(post) ; response = post.getResponseBodyAsString() ; if (statusCode != HttpStatus. SC_OK) { System. out.println(statusCode) ; }} finally { post.releaseConnection() ; } return response; }} 12
  • 13. Tap into your Linked Data endpoint import org.apache.commons.httpclient.* ; import org.apache.commons.httpclient.methods.PostMethod ; 13 org.apache.commons.httpclient.jar commons.io.jar import org.apache.commons.io.IOUtils ; sesame-query.jar import org.openrdf.query.TupleQueryResult ; import org.openrdf.query.TupleQueryResultHandlerException ; sesame-queryresultio-api.jar; sesame-queryresultio-sparqljson.jar import org.openrdf.query.resultio.QueryResultIO ; import org.openrdf.query.resultio.QueryResultParseException ; import org.openrdf.query.resultio.TupleQueryResultFormat ; import org.openrdf.query.resultio.UnsupportedQueryResultFormatException ;
  • 14. Display your Linked Data public void test() throws Exception { String value = ""; SPARQLendpointConnection myConncetion = new SPARQLendpointConnection( new URL("http: //vocabulary.semantic-web.at/PoolParty/sparql/cocktails" )); TupleQueryResult tqr = myConnection.runAndParseSelectQuery( "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> n" + "SELECT ?label WHERE { n" + "<http://vocabulary.semantic-web.at/cocktails/f3000285-36b0-4ffe-af90-740c2dd8fff5> skos:narrower ?p . n" + "?p skos:prefLabel ?label n" + "}"); BindingSet bs = null; try { while (tqr.hasNext()) { bs = tqr.next() ; value = bs.getValue( "label").toString() ; System.out.println(bs.getValue( "label")); }} finally { tqr.close() ; }} 14
  • 15. Display your Linked Data "Brandy"@en "Fortified wine"@en "Gin"@en "Liqueur"@en "Rum"@en "Schnapps"@en "Tequila"@en "Vodka"@en "Whisky"@en "Wine"@en 15 RESULTS
  • 16. Display your Linked Data private ModelAndView mavChooseIngredients; mavChooseIngredients = new ModelAndView( "cocktails/index" ); mavChooseIngredients .addObject( "myMenu", this.retrieveMainAlcoholicBeverages()) ; [..] public List<BindingSet> retrieveMainAlcoholicBeverages () throws IOException , QueryEvaluationException { return QueryResults. asList(myConnection .runAndParseSelectQuery( "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> n" + "SELECT ?label WHERE { n" + "<http://vocabulary.semantic-web.at/cocktails/f3000285-36b0-4ffe-af90- 740c2dd8fff5> skos:narrower ?p . n" + "?p skos:prefLabel ?label n" + "}" )); } 16
  • 17. Display your Linked Data <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core " %> <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions " %> [...] <c:forEach items="${myMenu}" var="bindingSet "> <li class="entity"> ${bindingSet.getValue( 'label').stringValue() } </li> </c:forEach> 17 index.jsp
  • 18. Display OPEN Linked Data DBpedia SPARQL endpoint: ▸ http://dbpedia.org/sparql SELECT * WHERE { <http://dbpedia.org/resource/Negroni> <http://dbpedia.org/ontology/abstract> ?abstract } 18
  • 19. The POWER of Linked data ▸ easy change of data ▸ cost efficient ▸ graph algorithms 19
  • 20. Place your screenshot here 20An improved SEARCH Faceted search http://preview.poolparty.biz/sparqlingCocktails/search
  • 22. Connect Timea Turdean Technical Consultant, Semantic Web Company ▸ timea.turdean@gmail.com ▸ http://at.linkedin.com/in/timeaturdean ▸ http://timeaturdean.com 22 © Semantic Web Company - http://www.semantic-web.at/ and http://www.poolparty.biz/
  • 23. ▸ LD2014 picture slide3- http://data.dws.informatik.uni- mannheim.de/lodcloud/2014/ ▸ Linked Data principles: http://www.w3. org/DesignIssues/LinkedData.html ▸ Introduction to Semantic Web: http://timeaturdean. com/introduction-semantic-web/ 23Resources