1

I’m a beginner in Semantic Web, I know a bit about what RDF does. Can someone kindly explain to me the following statements obtained from the book semantic web programming, Specially the syntax with semicolon (for example, rdf:type foaf:Person; and foaf: family name "Web")?

@prefix rdfs:
<http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf:
<http://xmlns.com/foaf/0.1/> .
@prefix admin:
<http://webns.net/mvcb/> .
@prefix owl:
<http://www.w3.org/2002/07/owl#> .
@prefix xsd:
<http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:
<http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix swp2:
<http://semwebprogramming.org/2009/ont/chp2#>.
< swp2:me>
rdf:type foaf:Person ;
foaf:depiction <http://semwebprogramming.org/semweb.jpg> ;
foaf:family name "Web" ;
foaf:givenname "Semantic" ;
foaf:homepage <http://semwebprogramming.org> ;
foaf:knows < swp2:Reasoner> , < swp2:Statement> , < swp2:
Ontology> ;
foaf:name "Semantic Web" ;
foaf:nick "Webby" ;
foaf:phone <tel:410-679-8999> ;
foaf:schoolHomepage <http://www.web.edu> ;
foaf:title "Dr" ;
foaf:workInfoHomepage
<http://semwebprogramming.com/dataweb.html> ;
foaf:workplaceHomepage
<http://semwebprogramming.com> 
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
kzs
  • 1,111
  • 5
  • 20
  • 35
  • 2
    The snippet you've posted is not a complete valid snippet in any RDF syntax that I know of (I'm assuming this is an incomplete cut and paste from a Turtle sample or SPARQL query), without a complete valid example your question is not going to get a good answer and is liable to be closed – RobV May 12 '14 at 12:44
  • Ok i have edited and given the complete copy paste :).. – kzs May 13 '14 at 04:44
  • so 'rdf : type foaf:Person' means we are referring to a 'type' 'Person' from the RDF schema 'foaf'? – – kzs May 13 '14 at 05:04
  • @anders_reimer yes. Your data (after the prefixes) begins with the subject `swp2:me`. (It doesn't look like you posted exact code, but rather that you edited it. E.g., `< swp2:me>` doesn't look like a valid URI. Are you sure that isn't actually `` or something? – Joshua Taylor May 13 '14 at 10:36
  • @Joshua, i copied the exact code from the textbook named semantic web programming. yap it's an example only, it's not a valid URI, rather they used the book's name to create an 'example' URI. They also represented 'semantic web' as a a foaf:person, you may have noticed..that too.. – kzs May 13 '14 at 10:50
  • @anders_reimer I assume you mean [this page](http://books.google.com/books?id=rtcIFmXkysEC&lpg=PA42&ots=tVk_9c_-DK&dq=semantic%20web%20programming%20foaf%3Adepiction&pg=PA42#v=onepage&q=semantic%20web%20programming%20foaf:depiction&f=false)? Yikes, there are some problems in that, but it also looks like some got introduced in copying and pasting. E.g., you lost the underscore in `foaf:family_name`, and the formatting changed a lot. It's worth noting that the pages around that example *do* describe what the RDF says, and points to a discussion of the Turtle format. – Joshua Taylor May 13 '14 at 10:56
  • You really should have mentioned that this text is from a book in the first place. It's almost certainly fair use to reproduce it like this to ask a question about it, but mentioning that it came from a book would allow people to get the context much more quickly. – Joshua Taylor May 13 '14 at 10:57
  • yes..i should have done that. – kzs May 13 '14 at 11:02

1 Answers1

2

As revealed in the comments, but not in the original posting, this sample RDF in the Turtle serialization is taken from Semantic Web Programming, page 42. There are some problems in the data with malformed URIs (e.g., < swp:me>), but the Google Books preview looks like it might be from a draft of the book. I don't know if those problems are present in the final printed copy.

The authors actually point you to Chapter 3 for more information about different serialization formats, but in this case, you just need to learn about the ; and , notation. The Turtle serialization It's very similar to the SPARQL query syntax, so you might benefit from the answer to Meaning of SPARQL operator ';'. In short, these syntaxes let you write

<subject> <predicate> <object> .

for a triple. Sometimes you have multiple triples with the same subject and predicate, in which case you'd have:

<subject> <predicate> <object1> .
<subject> <predicate> <object2> .

These syntaxes let you abbreviate this using a comma:

<subject> <predicate> <object1> , <object2> .

When you have multiple predicate-object pairs with the same subject, e.g.,

<subject> <predicateA> <object1> .
<subject> <predicateB> <object2> .

you can use a semicolon to abbreviate:

<subject> <predicateA> <object1> ;
          <predicateB> <object2> .

You can combine body of these abbreviations, too, so that you could turn

<subject> <predicateA> <object1a> .
<subject> <predicateA> <object2a> .
<subject> <predicateB> <object1b> .
<subject> <predicateB> <object2b> .

as

<subject> <predicateA> <object1a> ,
                       <object2a> ; 
          <predicateB> <object1b> ,
                       <object2b> .

If you fix the problems in the original data (malformed URIs) and the problems that arose from copy and paste problems (e.g., missing underscore in foaf:family_name), you'll end up with data like this:

@prefix swp2:  <http://semwebprogramming.org/2009/ont/chp2#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
@prefix admin: <http://webns.net/mvcb/> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

swp2:me  a                      foaf:Person ;
        foaf:depiction          <http://semwebprogramming.org/semweb.jpg> ;
        foaf:family_name        "Web" ;
        foaf:givenname          "Semantic" ;
        foaf:homepage           <http://semwebprogramming.org> ;
        foaf:knows              swp2:Reasoner , swp2:Statement , swp2:Ontology ;
        foaf:name               "Semantic Web" ;
        foaf:nick               "Webby" ;
        foaf:phone              <tel:410-679-8999> ;
        foaf:schoolHomepage     <http://www.web.edu> ;
        foaf:title              "Dr" ;
        foaf:workInfoHomepage   <http://semwebprogramming.com/dataweb.html> ;
        foaf:workplaceHomepage  <http://semwebprogramming.com> .

It's clear to see that using the ; and , abbreviations I discussed above, this document contains a bunch of triples whose subject is swp2:me. This aligns with the authors' description, in which they wrote (page 45):

These Semantic Web statements produced by the FOAF-a-Matic describe the person, Semantic Web, and friends. The statements form relationships. For example, the first grouping under #me declares information regarding the owner, the Semantic Web. The grouping of statements provides information about the owner's name, telephone number, and the like.

If you want to see all the triples explicitly, the N-Triples serialization, which puts one triple per line, is useful:

<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/workplaceHomepage> <http://semwebprogramming.com> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/knows> <http://semwebprogramming.org/2009/ont/chp2#Reasoner> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/phone> <tel:410-679-8999> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/knows> <http://semwebprogramming.org/2009/ont/chp2#Statement> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/workInfoHomepage> <http://semwebprogramming.com/dataweb.html> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/depiction> <http://semwebprogramming.org/semweb.jpg> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/givenname> "Semantic" .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/schoolHomepage> <http://www.web.edu> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/homepage> <http://semwebprogramming.org> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/title> "Dr" .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/nick> "Webby" .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/knows> <http://semwebprogramming.org/2009/ont/chp2#Ontology> .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/family_name> "Web" .
<http://semwebprogramming.org/2009/ont/chp2#me> <http://xmlns.com/foaf/0.1/name> "Semantic Web" .
Community
  • 1
  • 1
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • so 'rdf : type foaf:Person' means we are referring to a 'type' 'Person' from the RDF schema 'foaf'? – kzs May 13 '14 at 05:03
  • thank you so much, this is really helpful.So we use 'swp2:me a foaf:Person' instead of 'rdf:type foaf:Person' ? – kzs May 13 '14 at 10:57
  • 1
    `a` is just an abbreviation for `rdf:type` that can be convenient. In either case, you need a subject, predicate, and object. The subject is `swp2:me`, the predicate is `rdf:type`, and the object is `foaf:Person`. You can write that as `swp2:me rdf:type foaf:Person` or as `swp2:me a foaf:Person`. I've updated my answer now that we've identified the source of the data. Also take a look at the N-Triples serialization, as it shows exactly what the triples are, with no abbreviations. – Joshua Taylor May 13 '14 at 11:08
  • awesome, accepting the answer..your answers point me to new tools and resources such as rdfcat and N-triples serialization. – kzs May 13 '14 at 11:10