Shawn Simister

Developer Relations, Knowledge



  • Freebase
  • Schema.org
  • Knowledge Graph

Why do we need this?

Triplifying the web

  • Microdata
  • Microformats
  • RDFa
  • JSON-LD
  • Search
  • Google Now
  • Gmail
  • Maps

Am I doing it right?

"I was trying to implement a rich snippet for Google results with the person object. We list out doctors and hence we chose the Person object. Everything works great, for example, title, address, affiliation. The only thing which doesn't work is the photo."

- Stackoverflow user

Scaling developer outreach

Which approaches
did we consider?

SPIN Constraints

[ a       sp:Ask ;
  rdfs:comment "must be at least 18 years old"^^xsd:string ;
  sp:where ([ sp:object _:b1 ;
              sp:predicate ex:age ;
              sp:subject spin:_this
            ] [ a       sp:Filter ;
                sp:expression
                        [ a       sp:ge ;
                          sp:arg1 _:b1 ;
                          sp:arg2 18
                        ]
            ])
]

OWL Integrity Constraints

:Product rdfs:subClassOf [
         rdf:type owl:Restriction; 
         owl:onProperty :isManufacturedBy; 
         owl:someValuesFrom :Manufacturer 
   ] .
   :product1 rdf:type :Product .

What was our solution?

Our solution

  • Path-based constraints
  • SPARQL-based constraints
  • Prototyped using RDFlib
  • Engineers write constraints using JSON-LD
  • Targetted error messages in the UI

Path constraints

schema:reservationFor/schema:flightNumber
schema:reservationFor/schema:airline
schema:reservationFor/schema:airline/schema:name
schema:reservationFor/schema:airline/schema:iataCode
schema:reservationFor/schema:departureAirport
schema:reservationFor/schema:departureAirport/schema:name
schema:reservationFor/schema:departureAirport/schema:iataCode
schema:reservationFor/schema:departureTime
schema:reservationFor/schema:arrivalAirport
schema:reservationFor/schema:arrivalAirport/schema:name
schema:reservationFor/schema:arrivalAirport/schema:iataCode
schema:reservationFor/schema:arrivalTime

SPARQL constraints

{
  "@context": {...},
  "@id": "schema:FlightReservation",
  "constraints": [{
    "context": "schema:reservationFor",
    "constraint": "ASK WHERE {?constraint schema:boardingTime ?context. 
                   FILTER(?t > NOW())}",
    "severity": "warning",
    "message": "A future date is required to show a boarding pass.",
  }]
}

What did we learn?

Lessons learned

  • Most of our constraints are property paths
  • SPARQL handles the rest
  • Constraints describe the application; not the world that it inhabits
  • Constraints need to be app-specific

What's Next?

Next steps

  • More validation tools for more applications
  • Extracting all of the constraints from the code base
  • Switching from RDFlib to our own parser
  • Is SPARQL the right choice?
  • How do we publish and share our constraints?

Thank You!