Question

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> 
Was it helpful?

Solution

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" .
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top