Shorthand: Paths and Lists

 

 

Tim Berners-Lee

 

 

Decentralized Information Group
MIT Computer Science and Artificial Intelligence Laboratory

Semantic Web Tutorial

Shorthand: Paths and Lists

DanC, Sandro, and TimBL
$Id: index.html 2543 2007-01-10 03:14:52Z timbl $

Path-like phrases

An N3 expression for George's mother's assistant's home's address' zipcode:

[is con:zipcode of [
    is con:address of [
        is con:home of [
            is off:assistant of [
                is rel:mother of :George]]]]]

Special Syntax for paths

Shorter version of George's mother's assistant's home's address' zipcode using N3 path syntax:

:George!rel:mother
          !off:assistant
            !con:home
              !con:address
                 !con:zipcode

kinda like javascript, python, and other object-oriented programming langauges

Backward traversal

You can do backward traversal, using "^" instead of "!" as punctuation. For example, if we know Dan's mailbox...

:dan con:mailbox <mailto:connolly@w3.org>

then we can write this expression for Dan:

<mailto:connolly@w3.org>^con:mailbox

Note: This is rather unlike javascript, python, and other object-oriented programming langauges

Paths (example with diagram)

Joe, Joe's mother, and somebody whose boss is Joe's mother:

graphviz source, diagram in SVG, Makefile

Variables in paths

If somebody has a mailbox whose URI ends with w3.org, then they're a W3C person:

{
 ?x a con:Person.
 ?x!con:mailbox!log:uri!str:endsWith "@w3.org"
} => { ?x a :W3CPerson}

Some value, not the value

Note that there isn't necessarily only one match for a path - often there are many, when it is used on the left side of a rule.

:me!rel:parent

would be "Some x such that I have parent x", and

:me!rel:parent^rel:parent

would mean "Some y such that for some x, I had parent x and y had parent x", or loosely, some sibling of mine.

cwm only reads paths

Cwm doesn't currently use paths on output, so getting cwm to input and output a file will turn it into the form of N3 you already know.

Lists

(:x :y)

( :cust!bus:order!bus:number 
  :cust!bus:order
      !bus:referncedPurchaseOrder
          !bus:number )

What lists are short for

()
rdf:nil
("y")
[ rdf:first "y"; rdf:rest () ]
("x" "y")
[ rdf:first "x"; rdf:rest ("y") ]

What lists are short for (example)

( "Monday" "Tuesday" "Wednesday" )

short for

list diagram

Using lists for n-ary relationships

especially cwm built-ins:

(  "Dear " ?name " "," )   
             string:conatenation   ?salutation.

More Information



Creative Commons License
This work is licensed under a Creative Commons Attribution - Non-Commercial - No Derivatives 2.5 License.