ad529343370ac9b05969c25fe5c2102c.ppt
- Количество слайдов: 64
+ Internet of Things The Web of Data - JSON-LD, RDF, RDa 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 W 3 C and from Google’s adoption of RDFa and Microformats. 95 -733 Internet of Things
+ 95 -733 Internet of Things
+ Wo. T Architecture includes Thing Descriptions { "@context": ["https: //w 3 c. github. io/wot/w 3 c-wot-td-context. jsonld"], "@type": ["Thing"], "name": "My. Lamp. Thing", "interaction": [ { "@type": ["Property"], "name": "status", "schema": {"type": "string"}, "writable": false, "observable": true, "form": [{ "href": "coaps: //mylamp. example. com: 5683/status", "media. Type": "application/json" }] }, The Co. Ap binding says properties are got with a Co. Ap GET. A property may be read from a device. 95 -733 Internet of Things
+ Wo. T Architecture includes Thing Descriptions { "@type": ["Action"], "name": "toggle", "form": [{ "href": "coaps: //mylamp. example. com: 5683/toggle", "media. Type": "application/json" }] }, { } ] } "@type": ["Event"], "name": "overheating", "schema": {"type": "string"}, "form": [{ "href": "coaps: //mylamp. example. com: 5683/oh", "media. Type": "application/json" }] The Co. Ap binding says that actions are invoked with a Co. AP POST. Events with a Co. AP OBSERVE. Outsiders may invoke an action. Things may generate an event. 95 -733 Internet of Things
+ The Resource Description Framework Is All About Making Statements • An RDF Document contains Statements. • A statement can be thought of as an ordered triple composed of three items: (resource, property-type, property-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, NTriples 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. Ø Io. T is mostly about M 2 M interactions. 95 -733 Internet of Things
+ Each of these stores many RDF triples. 95 -733 Internet of Things
+ So, what’s a “triple”? A triple is a statement in some RDF format. The next slides shows how we can combine some triples into Knowledge Graph. 95 -733 Internet of Things
+ A Knowledge Graph 95 -733 Internet of Things
+ Triples Start Node Edge Label End Node vincent_donofrio starred_in law_&_order_ci is_a tv_show the_thirteenth_floor similar_plot_as the_matrix In Dbpedia, most widely used linking predicates are owl: same. As, rdfs: see. Also, foaf: knows 95 -733 Internet of Things
+ Different Formats (RDF/XML) <rdf: RDF xmlns: rdf="http: //www. w 3. 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> </rdf: RDF> 95 -733 Internet of Things In XML
+ Another RDF/XML <rdf: RDF xmlns: rdf="http: //www. w 3. org/1999/02/22 -rdf-syntax-ns#" xmlns: dc="http: //purl. org/dc/elements/1. 1/" xmlns: geo="http: //www. w 3. org/2003/01/geo/wgs 84_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: has. Dept rdf: resource="http: //www. cs. princeton. edu" dc: title="Department of Computer Science"/> </rdf: Description> </rdf: RDF> 95 -733 Internet of Things Another example
+ As A Table Subject Predicate Object ------------- ---- <http: //www. princeton. edu> edu: has. Dept <http: //www. cs. princeton. edu> <http: //www. princeton. edu> geo: lat <http: //www. princeton. edu> geo: long <http: //www. cs. princeton. edu> dc: title 95 -733 Internet of Things "40. 35" "-74. 66" "Department of Computer Science"
+ A triple may be 3 URI’s n How do we say “Billy Holiday was a songwriter” ? n With three URI’s: http: //dbpedia. org/resource/Billie_Holiday http: //dbpedia-owl: occupation http: //dbpedia. org/page/Songwriter An ontology might further say that all Songwriters are People. What deduction could we make? 95 -733 Internet of Things
+ RDFa and RDF n RDF stands on its own. Has many representations. n RDFa is a lightweight version of RDF for web pages. n RDFa is being used today by search engines like Google and sites like Best Buy. 95 -733 Internet of Things
+ How do we make these statements in a web page? 95 -733 Internet of Things
+ From the RDFa W 3 C Primer “When web data meant for humans is augmented with hints meant for computer programs, these programs become significantly more helpful. ” 95 -733 Internet of Things
+ XHTML Without and With RDFa All content on this site is licensed under <a href="http: //creativecommons. org/licenses/by/3. 0/"> a Creative Commons License </a> All content on this site is licensed under The rel, in a link, describes the relationship between the current page and the linked page. <a rel="license" href="http: //creativecommons. org/licenses/by/3. 0/"> a Creative Commons License </a>. 95 -733 Internet of Things
+ A Link with a Flavor 95 -733 Internet of Things
+ Labeling Title and Author <div> <h 2>The trouble with Bob</h 2> <h 3>Alice</h 3>. . . </div> RDFa introduces the property attribute. What kind of title? A title of a person or a title to land or a title of a work? <div xmlns: dc="http: //purl. org/dc/elements/1. 1/"> <h 2 property="dc: title">The trouble with Bob</h 2> <h 3 property="dc: creator">Alice</h 3>. . . </div> 95 -733 Internet of Things
+ In RDFa, all property names are, in fact, URLs. 95 -733 Internet of Things
+ Multiple Items Per Page RDFa provides @about, an attribute for <div about="/alice/posts/trouble_with_bob"> <h 2 property="dc: title">The trouble with Bob</h 2> specifying the <h 3 property="dc: creator">Alice</h 3> exact URL to. . . which the </div> contained RDFa markup <div about="/alice/posts/jos_barbecue"> <h 2 property="dc: title">Jo's Barbecue</h 2> applies <div xmlns: dc="http: //purl. org/dc/elements/1. 1/"> <h 3 property="dc: creator">Eve</h 3>. . . </div> 95 -733 Internet of Things
+ As a Diagram 95 -733 Internet of Things
+ Alice Gives Bob Credit <div about="/alice/posts/trouble_with_bob"> <h 2 property="dc: title">The trouble with Bob</h 2> The trouble with Bob is that he takes much better photos than I do: <div about="http: //example. com/bob/photos/sunset. jpg"> <img src="http: //example. com/bob/photos/sunset. jpg" /> <span property="dc: title">Beautiful Sunset</span> by <span property="dc: creator">Bob</span>. </div> The </div> inner about overrides the outer about. 95 -733 Internet of Things
+ As A Graph 95 -733 Internet of Things
+ Blog Contact Info <div> <p> Alice Birpemswick </p> <p> Email: <a href="mailto: alice@example. com">alice@example. com</a> </p> <p> Phone: <a href="tel: +1 -617 -555 -7332">+1 617. 555. 7332</a> </p> </div> This is mainly useful for viewing. 95 -733 Internet of Things
+ Blog w/FOAF Contact Info <div typeof="foaf: Person" xmlns: foaf="http: //xmlns. com/foaf/0. 1/"> <p property="foaf: name">Alice Birpemswick</p> <p>Email: <a rel="foaf: mbox" href="mailto: alice@example. com"> The Dublin core has no vocabulary for describing friendships. But foaf does. The typeof is an alice@example. com</a> RDFa attribute that is </p> specifically meant to <p> declare a new data Phone: <a rel="foaf: phone" item with href="tel: +1 -617 -555 -7332">+1 617. 555. 7332</a> a certain </p> type. </div> 95 -733 Internet of Things
+ As A Graph Alice didn't specify @about like she did when adding blog entry metadata. What is she associating these properties with, then? In fact, the @typeof on the enclosing div implicitly sets the subject of the properties marked up within that div. The name, email address, and phone number are associated with a new node of type foaf: Person. This 95 -733 Internet of Things node has no URL to identify it, so it is called a blank node.
+ Social Networks <div> <ul> <li> <a href="http: //example. com/bob/">Bob</a> </li> <a href="http: //example. com/eve/">Eve</a> </li> <a href="http: //example. com/manu/">Manu</a> </li> These people are all </ul> </div> friends of Alice and she Includes them in her normal HTML blog. 95 -733 Internet of Things
+ Adding RDFa First, describe these as 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 Use rel for the link relationships. <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
+ Describe Text as Names <div xmlns: foaf="http: //xmlns. com/foaf/0. 1/"> <ul> <li typeof="foaf: Person"> <a property="foaf: name" rel="foaf: homepage" href="http: //example. com/bob/">Bob</a> </li> <li typeof="foaf: Person"> <a property="foaf: name" rel="foaf: homepage" href="http: //example. com/eve/">Eve</a> </li> <li typeof="foaf: Person"> <a property="foaf: name" rel="foaf: homepage" href="http: //example. com/manu/">Manu</a> </li> </ul> 95 -733 Internet of Things </div>
+ Claim in Primer “Alice is ecstatic that, with so little additional markup, she's able to fully express both a pleasant human-readable page and a machine-readable dataset. ” 95 -733 Internet of Things
+ Using foaf: knows <div xmlns: foaf="http: //xmlns. com/foaf/0. 1/" about="#me" rel="foaf: knows"> <ul> <li typeof="foaf: Person"> <a property="foaf: name" rel="foaf: homepage" href="http: //example. com/bob">Bob</a> </li> <li typeof="foaf: Person"> <a property="foaf: name" rel="foaf: homepage" href="http: //example. com/eve">Eve</a> </li> <li typeof="foaf: Person"> <a property="foaf: name" rel="foaf: homepage" href="http: //example. com/manu">Manu</a> </li> </ul> </div> Alice knows these people with these names and homepages. 95 -733 Internet of Things
+ 95 -733 Internet of Things
+ Microformats Compete with RDFa Not from a standards body. A grassroots effort since 2004. h. Card Business card data XFN Friends and contacts h. Calendar Events h. Review movies, books, etc. . “When web data meant for humans is augmented with hints meant for computer programs, these programs become significantly more helpful. ” 95 -733 Internet of Things
+ Microformats Compete with RDFa As an exercise, visit: http: //microformats. org and build an h. Card an h. Calendar. Use h. Card creator and h. Calendar creator. Quiz. What information is requested by the XFN tool? 95 -733 Internet of Things
+ Google adopted Microformats and RDFa in 2009 Why? In support of “Rich Snippits”. “Google Rich Snippets provides structured data in Google search result snippets. Webmasters can provide this structured data by using microformats or RDFa to mark up their web pages. “ See the Rich Snippit Testing Tool at : http: //www. google. com/webmasters/tools/richsnippets 95 -733 Internet of Things
+ Rich Snippits “This kind of markup is designed for sites containing specific types of structured data. Google currently supports the following information types: reviews, people profiles, business listings, and events. ” From: http: //www. google. com/support/webmasters/bin/answer. py? hl=en&answer=99170 95 -733 Internet of Things
+ Examples from Google – A Review of a Pizza Joint The old way: <div> L’Amourita Pizza Reviewed by Ulysses Grant on Jan 6. Delicious, tasty pizza on Eastlake! L'Amourita serves up traditional wood-fired Neapolitan-style pizza, brought to your table promptly and without fuss. An ideal neighborhood pizza joint. Rating: 4. 5 </div> : 95 -733 Internet of Things
+ Examples from Google – A Review of a Pizza Joint With RDFa: <div xmlns: v="http: //rdf. data-vocabulary. org/#" typeof="v: Review"> <span property="v: itemreviewed">L’Amourita Pizza</span> Reviewed by <span property="v: reviewer">Ulysses Grant</span> on <span property="v: dtreviewed" content="2009 -01 -06">Jan 6</span>. <span property="v: summary">Delicious, tasty pizza on Eastlake!</span> <span property="v: description">L'Amourita serves up traditional wood-fired Neapolitan-style pizza, brought to your table promptly and without fuss. An ideal neighborhood pizza joint. </span> Rating: <span property="v: rating">4. 5</span> </div> 95 -733 Internet of Things Be sure to visit: http: //rdf. data-vocabulary. org/rdf. xml
+ Examples from Google – A Review of a Pizza Joint With Microformats: <div class="hreview"> <span class="item"> <span class="fn">L’Amourita Pizza</span> Reviewed by <span class="reviewer">Ulysses Grant</span> on <span class="dtreviewed"> Jan 6<span class="value-title" title="2009 -01 -06"> </span> <span class="summary">Delicious, tasty pizza on Eastlake!</span> <span class="description">L'Amourita serves up traditional wood-fired Neapolitan-style pizza, brought to your table promptly and without fuss. An ideal neighborhood pizza joint. </span> Rating: <span class="rating">4. 5</span> </div> 95 -733 Internet of Things
+ Quiz For RDFa documents, draw the corresponding knowledge graph. 95 -733 Internet of Things
+ JSON-LD Java. Script Object Notation for Linked Data 95 -733 Internet of Things
+ JSON-LD Support • W 3 C 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/knowledgegraph/reference/rest/v 1/ 95 -733 Internet of Things
+ From the JSON-LD specification at W 3 C n JSON-LD introduces: n A universal identifier mechanism for JSON objects via the use of IRIs n An IRI is an “International Resource Identifier”. An IRI allows non-ASCII characters. n A way to disambiguate keys shared among different JSON documents by mapping them to IRIs via a context n A mechanism in which a value in a JSON object may refer to a JSON object on a different site on the Web n The ability to annotate strings with their language n A way to associate datatypes with values such as dates and times n 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 (W 3 C) n An object structure is represented as a pair of curly brackets surrounding zero or more key-value pairs. n A key is a string. A single colon comes after each key, separating the key from the value. n A single comma separates a value from a following key. n In contrast to JSON, in JSON-LD the keys in an object must be unique. 95 -733 Internet of Things
+ JSON-LD Data Model (W 3 C) n The data model used for JSON-LD is a labeled, directed graph. n The graph contains nodes, which are connected by edges. n 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. n 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. n This is the RDF data model 95 -733 Internet of Things
+ JSON-LD Keywords (W 3 C) n @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. n @id Used to uniquely identify things that are being described in the document with IRIs or blank node identifiers. n @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 n @language to specify the language for a particular string value or the default language of a JSON-LD document. n @type to set the data type of a node or typed value. n 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": "Big. Blue. Hat", "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/", "given. Name": "Benjamin", "family. Name": "Young", "alternate. Name": "Big. Blue. Hat", "email": "byoung@bigbluehat. com" } Note: The value of @context is a string. The next slide will use an object as the value. Visit http: //schema. org/family. Name 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": "given. Name", "last_name": "family. Name", "alias": "alternate. Name", "first_name": "Benjamin", "last_name": "Young", "email": "email" "alias": "Big. Blue. Hat", "email": "byoung@bigbluehat. com" }, } 95 -733 Internet of Things http: //blog. codeship. com/json-ld-building-meaningful-data-apis/
+ Both examples above mean: [{ "http: //schema. org/alternate. Name": [ {"@value": "Big. Blue. Hat"}], "http: //schema. org/email": [{ "@value": "byoung@bigbluehat. com"}], "http: //schema. org/given. Name": [{"@value": "Benjamin”} ], "http: //schema. org/family. Name": [{ "@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 { name. Ja : { @id : http: //schema. org/name @language : “jp” } } name. Ja : “Mei” 95 -733 Internet of Things
+ JSON-LD and Io. T n 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", "contact. Point": { "@type": "Contact. Point", "telephone": "+1 -401 -555 -1212", "contact. Type": "customer service" } } </script> <!– Check out http: //schema. org/telephone --> 95 -733 Internet of Things
ad529343370ac9b05969c25fe5c2102c.ppt