linked data in use: schema.org, json-ld and hypermedia apis - front in bahia 2014

76
LINKED DATA IN USE

Upload: icaro-medeiros

Post on 28-Nov-2014

783 views

Category:

Software


0 download

DESCRIPTION

In my talk I walk throgh Semantic Web initiatives, like RDF and SPARQL, linked data principles, discuss some implementation and adoption issues and talk about semantic annotation in HTML. Semantic annotation using the Schema.org vocabulary is demonstrated using both HTML 5 Microdata or JSON-LD input. There is a strong highlight in benefits seen in Google search results with Rich Snippets, Actions in Email, and Google Now with real examples.

TRANSCRIPT

Page 1: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

LINKED DATA IN USE

Page 2: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Ícaro Medeiros [email protected] !Time de Semântica [email protected]

globo.com

Front in Bahia 13/9/2014

LINKED DATA IN USE

Schema.org, JSON-LD, and hypermedia APIs

Page 3: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

WHAT IS LINKED DATA?

Page 4: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

SEMANTIC WEB !

DONE RIGHT

Page 5: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

"I have a dream for the web in which computers become capable of analyzing all the data on the web - the content, links, and transactions between people and computers."

Tim Berners-Lee

Page 6: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

ROBERTO CARLOS GOAL AT MARACANÃ

Page 7: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

http://www.bbc.co.uk/blogs/legacy/radiolabs/s5/linked-data/s5.html

Page 8: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

http://www.bbc.co.uk/blogs/legacy/radiolabs/s5/linked-data/s5.html

Page 9: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Standard Vocabularies

• Dublin Core: publications

• FOAF: people

• SIOC: online communities

• DBPedia: Wikipedia in triples

Page 10: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Linked Data Principles

1. Use URIs as names for things

2. Use HTTP URIs so that people can look up those names.

3. When someone looks up a URI, provide useful information, using the standards (RDF*, SPARQL)

4. Include links to other URIs, so that they can discover more things.

Page 11: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Or…

1. Entity identity

2. Access

3. Structure

4. Integration

Page 12: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

RDF AND SPARQL

Page 13: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Triple representation

subject predicate object

Neymar is a player

Barcelona is a team

Neymar plays for Barcelona

Page 14: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

<Neymar> <Barcelona> <Santos>

<Player> <Time>

<BarcelonaXSantos:02082013><Partida>

is ais ais aplays for

is a

home team away team

<Camp Nou>

location

"2013/08/02"

date

Page 15: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

RDF triples

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. @prefix foaf: <http://xmlns.com/foaf/0.1/>. @prefix dbpedia: <http://dbpedia.org/ontology> !esportes:Neymar rdf:type dbpedia:SoccerPlayer ; rdfs:label "Neymar" ; foaf:name "Neymar da Silva Santos Júnior" ; dbpedia:birthDate "05/02/1992" ; owl:sameAs dbpedia:Neymar .

Linking!datasets

Page 16: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

LINKED DATASETS

Page 17: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

SPARQL query

Select all instances of dbpedia:SoccerPlayer class and its names !!!SELECT ?player ?name FROM <http://dbpedia.org> WHERE { ?player rdf:type dbpedia:SoccerPlayer ; rdfs:label ?name . }

Page 18: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

• Complexity (ontologies?)

• NO clear advantage

• Triplestore databases: immature

• Missing a killer application

• Fax problem

• Slow adoption

Problems

Page 19: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

LINKED DATA WITHOUT RDF?

Page 20: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

DON’T YOU WORRY ABOUT A

schema.org/Thing

Page 21: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

SCHEMA.ORG

Page 22: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014
Page 23: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

RICH SNIPPETS GOOGLE NOW

KNOWLEDGE GRAPH

CLEAR ADVANTAGE

Page 24: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

RICH SNIPPETS

City

Date

Location

Page 25: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014
Page 26: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

GMAIL

https://developers.google.com/gmail/actions/reference/flight-reservation?hl=pt-BR

Page 27: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

GOOGLE NOW

Page 28: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

MAPS

Page 29: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

SERP

Page 30: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

<html itemscope itemtype="http://schema.org/Event"> <head> <title itemprop="name"> Front in Maceió </title>

crawler! saves annotation! in KG

search results!enhanced

Page 31: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

ONE VOCABULARY TO RULE THEM ALL

Page 32: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

HOW TO DO IT?

Page 33: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

<html itemscope itemtype="http://schema.org/Event"> <head> <title itemprop="name"> Front in Bahia </title> ...

MICRODATA

Page 34: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

<html itemscope itemtype="http://schema.org/Event"> ... <section itemprop="location" itemscope itemtype="http://schema.org/Place"> <span itemprop="name">CESMAC</span> <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> <span itemprop="addressLocality"> Maceió </span> ...

NESTED PROPERTIES

Page 35: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Schema.org usage

• Sample 12B pages (Google Index)

• 6% domains

• ~21% pages

• Avg entities/page: 6

• Avg facts/page: 26

http://www.slideshare.net/rvguha/sem-tech2014c

Page 36: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

JSON-LD

Page 37: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Plain old JSON

{ "name": "Keith Urban", "url": "http://www.keithurban.net/tour/420", }

Page 38: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

{ "@context": "http://schema.org", "@type": "MusicEvent", "name": "Keith Urban", "url": "http://www.keithurban.net/tour/420", }

JSON-LD

Page 39: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Advantages

• Semantic layer on top of JSON

• Self-described

• Can be added to existing APIs

• JSON is extensively used

• Data can be anchored in schema.org

• Easy serialization to RDF

Page 40: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

JSON-LD AND HYPERMEDIA APIS

Page 41: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

GET /events/1 HTTP/1.1 Host: example.com ==================================== HTTP/1.0 200 OK ... Content-Type: application/json Link: <example.com/events/1.jsonld>; rel=http://www.w3.org/ns/json-ld#context; type=application/ld+json !{ "name": "Keith Urban", "url": "http://www.keithurban.net/tour/420", }

Client follows link!(hypermedia API)

Page 42: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

{ "@context": "http://schema.org", "@type": "MusicEvent", "@id": "/events/1", "name": "Keith Urban", "url": "http://www.keithurban.net/tour/420", }

Self-described Resource

Page 43: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

{ "@context": "http://schema.org", "@type": "MusicEvent", "@id": "/events/1", "name": "Keith Urban", "url": "http://www.keithurban.net/tour/420", "offers": [{ "@id": "/events/1/offer/1", "@type": "Offer" }]}

Client follows link

Resource+links

Page 44: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

JSON-SCHEMA

Page 45: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

GET /events/1 HTTP/1.1 Host: example2.com ==================================== HTTP/1.0 200 OK … Content-Type: application/json; profile=/events/1/_schema !{ "name": "Keith Urban", "url": "http://www.keithurban.net/tour/420", }

Client follows link (hypermedia API)

Schema in different resource

Page 46: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

GET /events/1/_schema HTTP/1.1 Host: example2.com ==================================== HTTP/1.0 200 OK … !{ "title": "Event", "type": "object", "properties": { "name": {"type": "string"}, "url": {"type": "url"} }, "links": { "rel": "offers", "href": "/events/1/offers" } }

Client does not know!URLs, just 'rel's

Page 47: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

HYPERMEDIA APIS

Page 48: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Hypermedia?

• Don’t remind URLS. Navigate!

• Decoupling server and client

• Content negotiation

• Application treated as State Machine

Page 49: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

/GET

{ "items": [ { "title": "News", "@id": "http://example.com/news/", "resource_id": "news" }, { "title": "Sports", "@id": "http://example.com/sports/", "resource_id": "sports" } ]

"links": [ { "href": “http://example.com/“, "rel": "self" }, { "href": "http://example.com/{resource_id}", "rel": "item" }, { "href": "http://example.com", "method": "POST", "rel": "create" }, { "href": "http://example.com/{resource_id}", "method": "DELETE", "rel": "delete" }, { "href": "http://example.com/?page=2", "method": "GET", "rel": "next" } ]

Page 50: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

/GET /sportsrel:item

resource_id:sports

GET

Page 51: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

self

/sports/Team/Barcelona

/sports/Team

inCollection

item

createdeletereplace

Relations

Page 52: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

JSON-LD IN HTML

Page 53: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

JSON-LD annotation<script type="application/ld+json"> [{ "@context": "http://schema.org", "@type": "MusicEvent", "name": "Keith Urban", "url": "http://www.keithurban.net/tour/420", "startDate": "2014-09-07", "performer": [{ "@type": "MusicGroup", "name": "Keith Urban", "sameAs": "http://www.keithurban.net"}],

www.keithurban.net/tourLinking!datasets

Same!vocabulary

Page 54: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

"location": { "@type": "Place", "name": "Sleep Train Amphitheatre", "address": { "@type": "PostalAddress", "addressLocality": "Sacramento", "addressState": "CA", "addressCountry": "US" }}, "offers": [{ "@type: "Offer", "name": "TICKETS", "url": "http://www.keithurban.net/tour/420" }]} //... ] </script>

Link is!followed!by crawler

Page 55: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

{ "@context": "http://schema.org", "@type": "MusicEvent", // ... "offers": [{ "@type": "Offer", "name": "General Tickets", "price": "40.00", "priceCurrency": "USD", "availability": "InStock", "validFrom": "2014-02-15T10:00", "category": "primary", "url": "www.axs.com/events/248328/keith-urban-tickets" }]}

keithurban.net/tour/420……..

Page 56: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

www.axs.com/events/248328/keith-urban-tickets

Page 57: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

JSON-LD IN EMAIL

Page 58: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "FlightReservation", "reservationNumber": "RXJ34P", "reservationStatus": "http://schema.org/Confirmed", "underName": { "@type": "Person", "name": "Eva Green" }, "reservationFor": { "@type": "Flight", "flightNumber": "110", "airline": { "@type": "Airline", "name": "United" }, //... </script>

Page 59: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

GMAIL

https://developers.google.com/gmail/actions/reference/flight-reservation?hl=pt-BR

Page 60: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

OPEN GRAPH

Page 61: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014
Page 62: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014
Page 63: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

TOOLS

Page 64: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

SCHEMA.ORG

Page 65: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

JSON-LD.ORG

Page 66: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

g.co/StructuredData

Page 67: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

http://www.google.com/webmasters/tools/richsnippets

Page 68: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

STRUCTURED DATA MARKUP HELPER

https://www.google.com/webmasters/markup-helper

Page 69: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

https://www.google.com/webmasters/markup-tester/

Page 70: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014
Page 71: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Semantic annotation goes a looong way

• +SEO

• +Mobile Rich Info

• Applications we don’t even know yet

Page 72: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

github.com/!globocom/

IWantToWorkAtGloboCom

Page 73: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

icaromedeiros.com.br

• Pelican (Python)

• Use ReStructuredText (rst) or Markdown

• Generate static pages

• Deploy to github pages easily

• github.com/icaromedeiros/pelican-microdata

Page 74: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

.. itemscope:: BusinessEvent :tag: p !

Today I have presented a talk in :itemprop:`Salvador <location>` at :itemprop:`Front in Bahia <name>`.

Page 75: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

<p itemscope itemtype="http://schema.org/BusinessEvent"> Today I have presented a talk in <span itemprop="location">Salvador</span> at <span itemprop="name">Front in Bahia</span>. </p>

Page 76: Linked Data in Use: Schema.org, JSON-LD and hypermedia APIs  - Front in Bahia 2014

Ícaro Medeiros [email protected]

!Semantic team

[email protected]

globo.com

slides icaromedeiros.com.br

slideshare.net/icaromedeiros