Slides for lightning talk, providing short introduction to the Semantic Web, and outlining current initiatives to work with semantic web technologies within the Ruby on Rails framework.
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Ruby on Rails and the Semantic Web
1. and the Semantic Web
Ruby on Rails
& &
Nathalie Steinmetz
(http://nathaliesteinmetz.net)
2. 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: HTML
Semantics: none
?
3. Semantic Web? So…
2001
Tim 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.”
4. Two main goals:
1. Describe real world objects in a structured way
2. 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>
5. 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>
6. Semantic Web: Linked Data
Linked Open Data Cloud:Google, Microsoft,
Facebook:
Bing
Snapshot
Google
Knowledge
Graph
Facebook
Graph Search
7. 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-unit
test "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