SuRF – Tapping into the Web of Data<br />Cosmin Basca<br />Digital Enterprise Research Institute, Galway<br />cosmin.basca...
Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />...
DERI – http://www.deri.ie/<br />Digital Enterprise Research Institute (DERI): <br />http://www.deri.ie/<br />main goal: en...
Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />...
Why ?<br />Develop Web applications that allow <br />Data Integration<br />Flexibility<br />Schema definition and modeling...
There is a Wealth of (RDF) data out there<br />6<br />
Popular Semantic Web Vocabularies<br />FOAF = for describing people and social network connections between them   http://x...
Linked Open Data - Growth<br />8<br />
Linked Open Data - Growth<br />9<br />
Linked Open Data - Growth<br />10<br />
The data model<br />Traditional Approach use the Relational model<br />Usually leads to big ugly Schemas<br />11<br />
The RDF (Graph) Data model<br />Flexible<br />Support for both schema and data evolution during runtime<br />Simple model<...
The RDF (Graph) Data model<br />13<br />Subject<br />Object<br />Predicate<br />A triple<br />is a <br />Eric<br />Person<...
Example RDF graph describing Eric Miller (RDF Primer) – human readable format<br />14<br />Person<br />is a <br />Eric<br ...
Example RDF graph describing Eric Miller (RDF Primer) – machine readable format<br />15<br />http://w3.org/2000/10/swap/pi...
The RDF (Graph) Data model – Identification <br />URI’s provide strong references<br />The URIref is a an unambiguous poin...
SPARQL – Querying the Semantic Web<br />SPARQL is to RDF what SQL is to Relational tables<br />Expressive, designed with t...
Levels of Data abstraction<br />18<br />Direct SPARQL<br />Access<br />O-RDF Mapper <br />SuRF<br />
O-RDF Mapper, Why?<br />Clean OO design<br />Increased productivity<br />model is free from persistence constraints<br />S...
O-RDF Mapper, How?<br />How do we see RDF data?<br />As a SET of triples?<br />As a SET of resources?<br />The resource vi...
Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />...
SuRF – Semantic Resource Framework<br />Inspired by ActiveRDF<br />Developed in DERI for ruby<br />Expose RDF as sets of r...
SuRF – Architecture<br />23<br />
SuRF – Architecture – Currently supported plugins<br />24<br />Add your own plugins, extend:<br />surf.store.plugins.RDFRe...
SuRF - installation<br />Available on PyPi<br />easy_install –U surf (to get the latest)<br />Open-source available on Goo...
Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />...
DBpedia public SPARQL endpoint - read-only<br />Create the store proxy<br />from surf import*<br />	store = Store(reader=&...
SuRF – simple example<br />DBpedia public SPARQL endpoint - read-only<br />Get all Phill Collins albums<br />all_albums=Ph...
Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />...
SuRF – integrate into Pylons<br />Create a blog on top of an RDF database<br />Replace SQLAlchemy with SuRF<br />Download ...
SuRF – Pylons Blog <br />~/MyBlog/development.ini: In the [app:main] section add<br />rdf_store = localhost<br />rdf_store...
SuRF – Pylons Blog <br />~/MyBlog/myblog/model/__ init __.py<br />from surf import *	<br />definit_model(session):<br />		...
SuRF – Pylons Blog <br />Create the template mkdir ~/MyBlog/myblog/templates/blog<br />~/MyBlog/myblog/templates/blog/inde...
SuRF – Tapping into the Web of Data<br />Can tap into the web of Data<br />SPARQL endpoints<br />Local or remote RDF Store...
exit()<br />cosmin.basca@deri.prg<br />http://code.google.com/p/surfrdf/<br />easy_install –U surf<br />35<br />
Upcoming SlideShare
Loading in...5
×

SuRf – Tapping Into The Web Of Data

4,224

Published on

SuRF is an Object - RDF Mapper based on the popular rdflib python library. It exposes the RDF triple sets as sets of resources and seamlessly integrates them into the Object Oriented paradigm of python in a similar manner as ActiveRDF does for ruby.

Published in: Education
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,224
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
27
Comments
0
Likes
11
Embeds 0
No embeds

No notes for slide

SuRf – Tapping Into The Web Of Data

  1. 1. SuRF – Tapping into the Web of Data<br />Cosmin Basca<br />Digital Enterprise Research Institute, Galway<br />cosmin.basca@gmail.com<br />Special Thanks to: Benjamin Heitman andUldis Bojars<br />Digital Enterprise Research Institute, Galway<br />firstname.lastname@deri.org<br />
  2. 2. Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />SPARQL<br />O-RDF Mapping (ActiveRDF / SuRF)<br />How?<br />Architecture<br />Installation<br />Examples<br />Simple: access DBpedia (Semantic Wikipedia)<br />More complex: create a blog on top of RDF<br />2<br />
  3. 3. DERI – http://www.deri.ie/<br />Digital Enterprise Research Institute (DERI): <br />http://www.deri.ie/<br />main goal: enabling networked knowledge<br />research about the future of the Web<br />biggest Semantic Web research institute in the world<br />120 people<br />part of the National University of Ireland, Galway<br />3<br />
  4. 4. Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />SPARQL<br />O-RDF Mapping (ActiveRDF / SuRF)<br />How?<br />Architecture<br />Installation<br />Examples<br />Simple: access DBpedia (Semantic Wikipedia)<br />More complex: create a blog on top of RDF<br />4<br />
  5. 5. Why ?<br />Develop Web applications that allow <br />Data Integration<br />Flexibility<br />Schema definition and modeling<br />Schema evolution<br />Robustness<br />Support for new Data <br />Sources<br />Types<br />5<br />
  6. 6. There is a Wealth of (RDF) data out there<br />6<br />
  7. 7. Popular Semantic Web Vocabularies<br />FOAF = for describing people and social network connections between them   http://xmlns.com/foaf/spec/<br />SIOC = for describing Social Web content created by people   http://sioc-project.org/<br />DOAP = for describing software projects   http://trac.usefulinc.com/doap<br />used by PyPi<br />7<br />
  8. 8. Linked Open Data - Growth<br />8<br />
  9. 9. Linked Open Data - Growth<br />9<br />
  10. 10. Linked Open Data - Growth<br />10<br />
  11. 11. The data model<br />Traditional Approach use the Relational model<br />Usually leads to big ugly Schemas<br />11<br />
  12. 12. The RDF (Graph) Data model<br />Flexible<br />Support for both schema and data evolution during runtime<br />Simple model<br />Relations are represented explicitly<br />Schema is a graph<br />Can integrate data – union of two graphs<br />12<br />
  13. 13. The RDF (Graph) Data model<br />13<br />Subject<br />Object<br />Predicate<br />A triple<br />is a <br />Eric<br />Person<br />
  14. 14. Example RDF graph describing Eric Miller (RDF Primer) – human readable format<br />14<br />Person<br />is a <br />Eric<br />has full name<br />Eric Miller<br />has e-mail<br />em@w3.org<br />has personal title<br />Dr.<br />
  15. 15. Example RDF graph describing Eric Miller (RDF Primer) – machine readable format<br />15<br />http://w3.org/2000/10/swap/pic/contact#Person<br />http://www.w3.org/1999/02/22-rdf-syntax-ns#type<br />http://w3.org/People/EM/contact#me<br />http://www.w3.org/2000/10/swap/pim/contact#fullName<br />Eric Miller<br />http://www.w3.org/2000/10/swap/pim/contact#mailbox<br />mailto:em@w3.org<br />http://www.w3.org/2000/10/swap/pim/contact#personalTitle<br />Dr.<br />
  16. 16. The RDF (Graph) Data model – Identification <br />URI’s provide strong references<br />The URIref is a an unambiguous pointer to something of meaning<br />Nodes (“Subjects”)<br /> connect via Links (“Predicates”)<br /> to Objects<br />Can be Nodes or Literals (plain or typed strings)<br />16<br />
  17. 17. SPARQL – Querying the Semantic Web<br />SPARQL is to RDF what SQL is to Relational tables<br />Expressive, designed with the Graph data model in mind<br />17<br />Carrie<br />Fisher<br />starred_in<br />Star<br />Wars<br />starred_in<br />Harrison<br />Ford<br />starred_in<br />Blade Runner<br />starred_in<br />Darryl<br />Hannah<br />SELECT ?actor ?movie WHERE {<br />?actor starred_in ?movie<br />}<br />
  18. 18. Levels of Data abstraction<br />18<br />Direct SPARQL<br />Access<br />O-RDF Mapper <br />SuRF<br />
  19. 19. O-RDF Mapper, Why?<br />Clean OO design<br />Increased productivity<br />model is free from persistence constraints<br />Separation of concerns and specialization<br />ORMs often reduce the amount of code needed to be written, making the software more robust<br />20% to 30% less code needs to be written<br />Less code – less testing – less errors<br />19<br />
  20. 20. O-RDF Mapper, How?<br />How do we see RDF data?<br />As a SET of triples?<br />As a SET of resources?<br />The resource view is more suitable for the OO model<br />How do we define an RDF resource ?<br />All triples &lt;S,P,O&gt;with same subject (ActiveRDF, SuRF)<br />And all triples &lt;O,P,S&gt; (SuRF)<br />Apply Open World principles<br />20<br />
  21. 21. Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />SPARQL<br />O-RDF Mapping (ActiveRDF / SuRF)<br />How?<br />Architecture<br />Installation<br />Examples<br />Simple: access DBpedia (Semantic Wikipedia)<br />More complex: create a blog on top of RDF<br />21<br />
  22. 22. SuRF – Semantic Resource Framework<br />Inspired by ActiveRDF<br />Developed in DERI for ruby<br />Expose RDF as sets of resources<br />Semantic attributes exposed as a “virtual API”, generated through introspection. <br />Naming convention:<br />instance.namespace_attribute<br />cosmin.foaf_knows<br />Finder methods<br />Retrieve resources by type or by attributes<br />Session keeps track of resources, when calling session.commit() only dirty resources will be persisted<br />22<br />
  23. 23. SuRF – Architecture<br />23<br />
  24. 24. SuRF – Architecture – Currently supported plugins<br />24<br />Add your own plugins, extend:<br />surf.store.plugins.RDFReader<br />surf.store.plugins.RDFWriter<br />Redefine the __type__ attribute<br />This is the plugin identifier<br />To install plugins<br />import my_plugin<br />
  25. 25. SuRF - installation<br />Available on PyPi<br />easy_install –U surf (to get the latest)<br />Open-source available on Google Code, BSD licence<br />http://code.google.com/p/surfrdf/<br />25<br />
  26. 26. Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />SPARQL<br />O-RDF Mapping (ActiveRDF / SuRF)<br />How?<br />Architecture<br />Installation<br />Examples<br />Simple: access DBpedia (Semantic Wikipedia)<br />More complex: create a blog on top of RDF<br />26<br />
  27. 27. DBpedia public SPARQL endpoint - read-only<br />Create the store proxy<br />from surf import*<br /> store = Store(reader=&apos;sparql-protocol&apos;,endpoint=&apos;http://dbpedia.org/sparql&apos;,                default_graph=&apos;http://dbpedia.org&apos;)<br />Create the surf session<br />print&apos;Create the session&apos;session =Session(store,{})<br />Map a dbpedia concept to an internal class<br />PhilCollinsAlbums=session.get_class(ns.YAGO[&apos;PhilCollinsAlbums&apos;])<br />SuRF – simple example<br />27<br />
  28. 28. SuRF – simple example<br />DBpedia public SPARQL endpoint - read-only<br />Get all Phill Collins albums<br />all_albums=PhilCollinsAlbums.all()<br />Do something with the albums (display the links to their covers)<br />print&apos;All covers&apos;for a inall_albums:    ifa.dbpedia_name:        print&apos; Cover %s for &quot;%s&quot;&apos;%(a.dbpedia_cover,a.dbpedia_name)<br />28<br />
  29. 29. Outline<br />About DERI<br />Why Semantic Web?<br />Linked Open Data (LOD)<br />RDF (Resource Description Framework)<br />SPARQL<br />O-RDF Mapping (ActiveRDF / SuRF)<br />How?<br />Architecture<br />Installation<br />Examples<br />Simple: access DBpedia (Semantic Wikipedia)<br />More complex: create a blog on top of RDF<br />29<br />
  30. 30. SuRF – integrate into Pylons<br />Create a blog on top of an RDF database<br />Replace SQLAlchemy with SuRF<br />Download and install either AllegroGraph Free Edition (preferred) or Sesame2<br />http://www.franz.com/downloads/clp/ag_survey<br />Free for up to 50.000.000 triples (records)<br />Install pylons: easy_install pylons<br />Install SuRF: easy_install surf<br />Create a pylons application:<br />paster create -t pylons MyBlog<br />cd MyBlog<br />30<br />
  31. 31. SuRF – Pylons Blog <br />~/MyBlog/development.ini: In the [app:main] section add<br />rdf_store = localhost<br />rdf_store_port = 6789<br />rdf_repository = tagbuilder<br />rdf_catalog = repositories<br />~/MyBlog/myblog/config/environment.py<br />from surf import *<br />rdf_store = Store( reader = &apos;sparql-sesame2-api&apos;,<br /> writer = &apos;sesame2-api&apos;,<br /> server = config[&apos;rdf_store&apos;],<br /> port = config[&apos;rdf_store_port&apos;],<br /> catalog = config[&apos;rdf_catalog&apos;],<br /> repository = config[&apos;rdf_repository&apos;])<br />rdf_session = Session(rdf_store, {})<br />31<br />
  32. 32. SuRF – Pylons Blog <br />~/MyBlog/myblog/model/__ init __.py<br />from surf import * <br />definit_model(session):<br /> global rdf_session<br />rdf_session = session<br /> # register a namespace for the concepts in my blog<br />ns.register(myblog=‘http://example.url/myblog/namespace#’)<br />Blog = rdf_session.get_class(ns.MYBLOG[‘Blog’])<br />Create the blog controllerpaster controller blog<br />~/MyBlog/myblog/controllers/blog.py<br />import logging <br />frommyblog.lib.baseimport * <br />log = logging.getLogger(__name__) <br />classBlogController(BaseController): <br />def index(self): <br />c.posts = model.Blog.all(0,5)<br />return render(&quot;/blog/index.html&quot;)<br />32<br />
  33. 33. SuRF – Pylons Blog <br />Create the template mkdir ~/MyBlog/myblog/templates/blog<br />~/MyBlog/myblog/templates/blog/index.html <br />&lt;%inherit file=&quot;site.html&quot; /&gt; <br />&lt;%def name=&quot;title()&quot;&gt;MyBlog Home&lt;/%def&gt; <br />&lt;p&gt;${len(c.posts)} new blog posts!&lt;/p&gt; <br />% for post inc.posts: <br />&lt;p class=&quot;content&quot; style=&quot;border-style:solid;border-width:1px&quot;&gt; <br />&lt;span class=&quot;h3&quot;&gt; ${post.myblog_title} &lt;/span&gt; <br />&lt;span class=&quot;h4&quot;&gt;Posted on: ${post.myblog_date} by ${post.myblog_author}&lt;/span&gt; <br />&lt;br&gt; ${post.myblog_content} <br />&lt;/p&gt; <br />% endfor<br />~/MyBlog/myblog/templates/blog/site.html<br />Start the development built in server:<br />paster serve --reload development.ini<br />33<br />
  34. 34. SuRF – Tapping into the Web of Data<br />Can tap into the web of Data<br />SPARQL endpoints<br />Local or remote RDF Stores<br />Plugin framework, allows for more access protocols to be defined<br />Code is generated dynamically (pragmatic bottom up approach):<br />Introspection, meta-programming, <br />exposing a virtual API (defined by the data and the schema) to the developer<br />Can easily be integrated into popular python frameworks<br />pylons<br />34<br />
  35. 35. exit()<br />cosmin.basca@deri.prg<br />http://code.google.com/p/surfrdf/<br />easy_install –U surf<br />35<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×