390 likes | 406 Views
+. Internet of Things. The Web of Data – RDF and JSON-LD. 95-733 Internet of Things. +. RDF and RDFa. Or, Why Can’t Google Find My Lost Keys?. Notes from three articles on course schedule: “ What is RDF ” by Tim Bray and Joshua Tauberer, the “ RDFa
E N D
+ Internet of Things The Web of Data – RDF and JSON-LD 95-733 Internet of Things
+ RDF and RDFa Or, Why Can’t Google Find My Lost Keys? Notes from three articles on course schedule: “What is RDF” by Tim Bray and Joshua Tauberer, the “RDFa Primer” from W3C and from Google’s adoption of RDFa and Microformats. 95-733 Internet of Things
+ 95-733 Internet of Things 95-733 Internet of Things
+ The Resource Description Framework Is All About Making Statements • An RDF Document or JSON-LD message contains Statements. • A statement can be thought of as an ordered triple composed of three items: (resource, predicate, value) • A Resource is anything that can be identified. • A Predicate is a property name that has a URI. The Predicate may or may not actually be resolvable. • A Value is another Resource or a literal. • Statements may be represented in RDF XML, abbreviated RDF XML, N- Triples or graphs or JSON-LD. • The whole idea is to make unambiguous statements! 95-733 Internet of Things
+ First: Let’s get some RDF curl --include --location --header "Accept:application/rdf+xml" http://dbpedia.org/resource/Yukihiro_Matsumoto How about Satoshi_Nakamoto? For human readable information, see the corresponding https://en.wikipedia.org/wiki/Satoshi_Nakamoto curl --include --location --header "Accept:application/rdf+xml" http://dbpedia.org/resource/Sirius Who is this for? The web for programmers. Can we describe things like we do people and stars? 95-733 Internet of Things
+ Each of these stores many many RDF triples. 95-733 Internet of Things
+ As of 2019 95-733 Internet of Things
+A Knowledge Graph from Triples 95-733 Internet of Things
+Triples Start Node Edge Label End Node vincent_donofrio law_&_order_ci the_thirteenth_floor similar_plot_as the_matrix starred_in is_a law_&_order_ci tv_show In Dbpedia, most widely used linking predicates are owl:sameAs, rdfs:seeAlso, foaf:knows 95-733 Internet of Things
+Different Formats (RDF/XML) <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://www.example.org/"> <rdf:Description rdf:about="http://www.example.org/vincent_donofrio"> <ex:starred_in> <ex:tv_show rdf:about="http://www.example.org/law_and_order_ci" /> </ex:starred_in> </rdf:Description> <rdf:Description rdf:about="http://www.example.org/the_thirteenth_floor"> <ex:similar_plot_as rdf:resource="http://www.example.org/the_matrix" /> </rdf:Description> In XML </rdf:RDF> 95-733 Internet of Things
+Another RDF/XML <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:geo="http://www. w3.org/2003/01/geo/wgs84_pos#" xmlns:edu="http://www.example.org/"> <rdf:Description rdf:about="http://www.princeton.edu"> <geo:lat>40.35</geo:lat> <geo:long>-74.66</geo:long> <edu:hasDept rdf:resource="http://www.cs.princeton.edu" dc:title="Department of Computer Science"/> </rdf:Description> Another example </rdf:RDF> 95-733 Internet of Things
+As A Table Subject Predicate Object -------------------------- ----------- -------- <http://www.princeton.edu> edu:hasDept <http://www.cs.princeton.edu> <http://www.princeton.edu> geo:lat "40.35" <http://www.princeton.edu> geo:long "-74.66" <http://www.cs.princeton.edu> dc:title "Department of Computer Science" 95-733 Internet of Things
+A triple may be 3 URI’s How do we say “Billy Holiday was a songwriter” ? With three URI’s: http://dbpedia.org/resource/Billie_Holiday http://dbpedia-owl:occupation http://dbpedia.org/page/Songwriter In an ontology, we might learn that that all Songwriters are People. What deduction could we make? 95-733 Internet of Things
+ RDFa and RDF RDF stands on its own. Has many representations. RDFa is a lightweight version of RDF for web pages. RDFa is being used today by search engines like Google and sites like Best Buy. JSON-LD is being supported by W3C for WoT. 95-733 Internet of Things
+ With RDFa, we can make these statements in a web page. 95-733 Internet of Things
+Adding RDFa Describing persons. <div xmlns:foaf="http://xmlns.com/foaf/0.1/"> <ul> <li typeof="foaf:Person"> <a href="http://example.com/bob/">Bob</a> </li> <li typeof="foaf:Person"> <a href="http://example.com/eve/">Eve</a> </li> <li typeof="foaf:Person"> <a href="http://example.com/manu/">Manu</a> </li> </ul> </div> 95-733 Internet of Things
+Add Homepages Describing relationships with rel attribute. <div xmlns:foaf="http://xmlns.com/foaf/0.1/"> <ul> <li typeof="foaf:Person"> <a rel="foaf:homepage" href="http://example.com/bob/">Bob</a> </li> <li typeof="foaf:Person"> <a rel="foaf:homepage" href="http://example.com/eve/">Eve</a> </li> <li typeof="foaf:Person"> <a rel="foaf:homepage" href="http://example.com/manu/">Manu</a> </li> </ul> </div> 95-733 Internet of Things
+ JSON-LD JavaScript Object Notation for Linked Data 95-733 Internet of Things
+JSON-LD Support • W3C Recommendation 16 January 2014 • Supported by Google and Facebook • Supported by Google for Product and Review Rich Snippits (may be included in an HTML script tag) • Returned by queries on Google’s Knowledge graph. See: https://developers.google.com/knowledge-graph/ https://developers.google.com/knowledge- graph/reference/rest/v1/ 95-733 Internet of Things
+From the JSON-LD specification at W3C JSON-LD introduces: A universal identifier mechanism for JSON objects via the use of IRIs An IRI is an “International Resource Identifier”. An IRI allows non-ASCII characters. A way to disambiguate keys shared among different JSON documents by mapping them to IRIs via a context A mechanism in which a value in a JSON object may refer to a JSON object on a different site on the Web The ability to annotate strings with their language A way to associate datatypes with values such as dates and times and a facility to express one or more directed graphs, such as a social network, in a single document. 95-733 Internet of Things
+JSON Object (W3C) An object structure is represented as a pair of curly brackets surrounding zero or more key-value pairs. A key is a string. A single colon comes after each key, separating the key from the value. A single comma separates a value from a following key. In contrast to JSON, in JSON-LD the keys in an object must be unique. 95-733 Internet of Things
+WoT Architecture includes Thing Descriptions { "@type": ["Action"], "name": "toggle", "form": [{ "href": "coaps://mylamp.example.com:5683/toggle", "mediaType": "application/json" }] }, { "@type": ["Event"], "name": "overheating", "schema": {"type": "string"}, "form": [{ "href": "coaps://mylamp.example.com:5683/oh", "mediaType": "application/json" }] } ] } Outsiders may invoke an action. Things may generate an event. The CoAp binding says that actions are invoked with a CoAP POST. Events with a CoAP OBSERVE. 95-733 Internet of Things
+WoT Architecture includes Thing Descriptions { "@context": ["https://w3c.github.io/wot/w3c-wot-td-context.jsonld"], "@type": ["Thing"], "name": "MyLampThing", "interaction": [ { "@type": ["Property"], "name": "status", "schema": {"type": "string"}, "writable": false, "observable": true, "form": [{ "href": "coaps://mylamp.example.com:5683/status", "mediaType": "application/json" }] }, The CoAp binding says properties are got with a CoAp GET. A property may be read from a device. 95-733 Internet of Things
+JSON-LD Data Model (W3C) The data model used for JSON-LD is a labeled, directed graph. The graph contains nodes, which are connected by edges. A node is typically data such as a string,number,typed values (like dates and times) or an IRI. There is also a special class of node called a blank node, which is typically used to express data that does not have a global identifier like an IRI. Blank nodes are identified using a blank node identifier. This simple data model is incredibly flexible and powerful, capable of modeling almost any kind of data. This is the RDF data model 95-733 Internet of Things
+JSON-LD Keywords (W3C) @context Used to define the short-hand names that are used throughout a JSON-LD document. These short-hand names are called terms and help developers to express specific identifiers in a compact manner. @id Used to uniquely identify things that are being described in the document with IRIs or blank node identifiers. @value Used to specify the data that is associated with a particular property in the graph. 95-733 Internet of Things
+More JSON-LD Keywords @language to specify the language for a particular string value or the default language of a JSON-LD document. @type to set the data type of a node or typed value. See the spec for a description of the keywords @container, @list,@set,@reverse,@index,@base,@vocab,@graph 95-733 Internet of Things
+Normal JSON with only implied meaning (Not very helpful.) { "first_name": "Benjamin", "last_name": "Young", "alias": "BigBlueHat", "email": "byoung@bigbluehat.com" } http://blog.codeship.com/json-ld-building-meaningful-data-apis/ 95-733 Internet of Things
+With unambiguous meaning { "@context": "http://schema.org/", "givenName": "Benjamin", "familyName": "Young", Note: The value of @context is a string. "alternateName": "BigBlueHat", "email": "byoung@bigbluehat.com" The next slide will use an object as the value. } Visit http://schema.org/familyName if unsure about the definition. http://blog.codeship.com/json-ld-building-meaningful-data-apis/ 95-733 Internet of Things
+Establishing aliases { "@context": { "@vocab": "http://schema.org/", "first_name": "givenName", "last_name": "familyName", "alias": "alternateName", "first_name": "Benjamin", "last_name": "Young", "alias": "BigBlueHat", "email": "byoung@bigbluehat.com" } "email": "email" }, 95-733 Internet of Things http://blog.codeship.com/json-ld-building-meaningful-data-apis/
+Both examples above mean: [ { "http://schema.org/alternateName": [ {"@value": "BigBlueHat"}], "http://schema.org/email": [{ "@value": "byoung@bigbluehat.com"}], "http://schema.org/givenName": [{"@value": "Benjamin”} ], "http://schema.org/familyName": [{ "@value": "Young"}] } ] and tools will know this. 95-733 Internet of Things
+Object typing (from Manu Sporny) Objects can be given a specific type { “@context” : { … } , “@type” : “Person”, “name” : “Mike” : } Person, using the context, expands to a URI. Name is a property that also expands to a URI. 95-733 Internet of Things
+Data typing (From Manu Sporny) Give a birthday property a value and a type. { “@context” : { … } , “@type” : “Person”, “name” :”Mike”, “birthday” : { “@value” : “2000-01-01”, “@type” : “xsd:date” } 95-733 Internet of Things
+Data typing (From Manu Sporny) Again, with aliasing in the context... { “@context” : { “birthday” : { “@id” : http://schema.org/birthday, “@type” : “xsd:date” } }, “birthday” : “2000-01-01” } 95-733 Internet of Things
+Embedding (From Manu Sporny) Suppose Natasha knows Boris. { @context : {…} “name” : “Natasha”, “knows: { “name” : “Boris” } } 95-733 Internet of Things
+Referencing (From Manu Sporny) Again, but with a URL { @context : {…} “name” : “Natasha”, “knows” : “http://people.org/Boris” } In the context, we have stated that the value of “knows” is a URL. 95-733 Internet of Things
+Keyword aliasing (From Manu Sporny) { @context : { “id” : “@type”, “type” : “@type”, “url” : “@id”, : id : type : url: } 95-733 Internet of Things
+Internationalization (From Manu Sporny) context { nameJa : { @id : http://schema.org/name @language : “jp” } } nameJa : “Mei” 95-733 Internet of Things
+ JSON-LD and IoT Suppose a thermostat reports a temperature. Is it cold or really hot? { “temperature”: 40 } How could JSON-LD help? Will may be able to ask Google “Find my lost keys”. 95-733 Internet of Things
+Google recommends the use of JSON-LD <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Organization", "url": "http://www.your-company-site.com", "contactPoint": { "@type": "ContactPoint", "telephone": "+1-401-555-1212", "contactType": "customer service" } } </script> <!– Check out http://schema.org/telephone --> 95-733 Internet of Things