and the Semantic Web Ruby on Rails & & Nathalie Steinmetz (http://nathaliesteinmetz.net)
Nov 02, 2014
and the Semantic Web
Ruby on Rails
& &
Nathalie Steinmetz (http://nathaliesteinmetz.net)
Semantic Web? Wait, what’s that?
I love Ruby on Rails
I Ruby on Rails
vs.
Syntax vs. semantics of a sentence:
On the Web:
codefellows.org
Syntax: HTMLSemantics: none
?
Semantic Web? So…
2001Tim Berners-Lee
A Web of data:
“The Semantic Web provides a common framework that allows data to be shared and reused across application, enterprise, and community boundaries.”
Two main goals:1. Describe real world objects in a structured way2. Integrate and combine data from different sources
Semantic Web: RDF & vocabularies
Main language: RDF
Nathalie Ruby on Rails
likes
Subject Predicate Object
Use existing vocabularies:
FOAF
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://example.org/vocabulary#"> <ex:Nathalie> <ex:likes><ex:Ruby_on_Rails>
</rdf:RDF>
Semantic Web: in action
How to markup web pages:
Schema.org – recognized by Bing, Google, Yahoo and Yandex:
RDFa:Embedding RDF into HTML
JSON-LD:Lightweight Linked Data format based on JSON
Microdata:Embedding machine-readable data into HTML
<div> <h1>Avatar</h1> <span>Director: James Cameron (born August 16, 1954)</span> <span>Science fiction</span> <a href="../movies/avatar-theatrical-trailer.html">Trailer</a> </div>
<div itemscope itemtype ="http://schema.org/Movie"> <h1 itemprop="name“ Avatar</h1> <div itemprop="director" itemscope itemtype="http://schema.org/Person"> Director: <span itemprop="name">James Cameron</span> (born <span itemprop="birthDate">August 16, 1954)</span> </div> <span itemprop="genre">Science fiction</span> <a href="../movies/avatar-theatrical-trailer.html" itemprop="trailer">Trailer</a> </div>
Semantic Web: Linked Data
Linked Open Data Cloud:Google, Microsoft, Facebook:
Bing Snapshot
Google Knowledge Graph
Facebook Graph Search
Semantic Web on Rails
Ruby RDF Project: ruby-rdf.github.io
Automated testing of HTML5 microdata:
Contains numerous gems supporting Linked Data and Semantic Web programming:
• gem ‘rdf’• gem ‘rdf-rdfa’• gem ‘rdf-microdata’• gem ‘json-ld’• rack middleware ‘rack-sparql’• rack middleware ‘rack-sesame’
• gem linkeddata (combination of several gems)
Ruby library for extracting HTML5 microdata:• gem ‘microdata’
Integration tests using test-unittest "the top level item is a schema.org/Person" do assert_equal ['http://schema.org/Person'],
@items.first.type end test "the Person should have a name, url, and job title" do person = @items.first assert_equal ['Jason Ronallo'], person.properties['name'] assert_equal ['http://twitter.com/ronallo'],
person.properties['url'] assert_equal ['Ass. Head of Digital Library Initiatives'],
person.properties['jobTitle'] end
Questions?
More info at:
Semantic Web: http://www.w3.org/standards/semanticweb/
RDF: http://www.w3.org/standards/techs/rdf#w3c_all
RDFa: http://rdfa.info/
JSON-LD: http://json-ld.org/
RDF.rb: http://rdf.rubyforge.org/
Ruby RDF project: http://ruby-rdf.github.io/
HTML5 microdata test: http://jronallo.github.io/blog/automated-testing-of-html5-microdata-in-rails/