RDF using N3 Subject, Verb and Object All knowledge is just a set of statements <#pat> <#knows> <#jo> . Everything is identified by URI Here a local URI but could point to ANY document Verb known as predicate in the statement and represents a Property. The period at the end – very important Object Can Be Literal <#pat> <#knows> <#jo> . <#pat> <#age> "24" . Note: noun form "age" preferred to the verb style "knows" for predicates Alternative Forms <#pat> has <#child> <#al> . Just to make reading easier; no meaning <#al> is <#child> of <#pat> . is and of reverse the direction Saves having inverse relationships for everything (eg parent) Comma and Semicolon <#pat> <#child> <#al>, <#chaz>, <#mo> ; <#age> "24" ; <#eyecolor> "blue" . Comma: delimits multiple objects for same subject & predicate Semicolon: delimits multiple predicates for same subject. Aim? Easy scribbling of data. Data …e.g. a table age eyecolor pat 24 blue al 3 green jo 5 green <#pat> <#age> "24"; <#eyecolor> "blue" . <#al> <#age> "3"; <#eyecolor> "green" . <#jo> <#age> "5"; <#eyecolor> "green" . Unnamed Things: Square Brackets <#pat> <#child> [ <#age> "4" ] , [ <#age> "3" ]. Words used as IDs have no actual meaning Unnamed nodes can't be used elsewhere ID things are names; make the name explicit [ <#name> "Pat"; <#age> "24"; <#eyecolor> "blue" ]. [ <#name> "Al" ; <#age> "3"; <#eyecolor> "green" ]. [ <#name> "Jo" ; <#age> "5"; <#eyecolor> "green" ]. Sharing Concepts Using the same URIs is effort but valuable For anything -- including predicates URIs tend to be long so we use namespaces Writing authoritative documents about shared concepts is useful Local Concept <> <#title> "A simple example of N3". Who or what knows what <#title> is? Shared Concept <http://purl.org/dc/elements/1.1/title> "Primer Getting into the Semantic Web and RDF using N3". @prefix dc: <http://purl.org/dc/elements/1.1/> . <> dc:title "Primer - Getting into the Semantic Web and RDF using N3". No <> used when prefixed identifier Typically prefix stands for everything up to including a "#" Assumed Prefixes In this tutorial: @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . and also @prefix : <#> . e.g. :pat :child [ :age "4" ] , [ :age "3" ]. RDF Conversion <RDF xmlns="http://www.w3.org/1999/02/22-rdfsyntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdfsyntax-s#" xmlns:rdfs="http://www.w3.org/2000/01/rdfschema#" xmlns:owl="http://www.w3.org/2002/07/owl#" /> Making Vocabularies A set of shared concepts Properties are things to use as predicates (verbs) Classes can be the type of an object rdf:type is just a property, abbreviated to "a" in N3 Cont. Equivalent: :Person rdf:type rdfs:Class :Person a rdfs:Class. Which we could use with data: :Pat a :Person. Classes An object can be in many classes Classes can have many superclasses You can never know all the classes an object is in These are classes of real things, not OO classes Examples: class and property :Woman a rdfs:Class; rdfs:subClassOf :Person . :sister a rdf:Property. Something about the Property :sister:: :sister rdfs:domain :Person; rdfs:range :Woman. Use: :Pat :sister :Jo. Class ids start with capital, Propoerty ids with lowercase Best Practice Use other people's terms when you can Use your own when you need to Be prepared to declare them equivalent later = in N3 is short for owl:equivalentTo :Woman = foo:FemaleAdult . :title a rdf:Property; = dc:title . Examples English (Very Informal): There is person, Pat, known as "Pat Smith" and "Patrick Smith". Pat has a pet dog named "Rover". English Hypertext (Informal): Ambiguity of terms is removed by links Pat is a human with the names "Pat Smith" and "Patrick Smith". Pat has a pet, a dog, with the name "Rover". N3 @prefix : <http://www.w3.org/2000/10/swap/test/demo1/about-pat#> . @prefix bio: <http://www.w3.org/2000/10/swap/test/demo1/biology#> . @prefix per: <http://www.w3.org/2000/10/swap/test/demo1/friendsvocab#> . :pat a bio:Human; per:name "Pat Smith", "Patrick Smith"; per: pet [ a bio:Dog; per:name "Rover" ] . Directed Labeled Graph RDF Translation <rdf:RDF xmlns="http://www.w3.org/2000/10/swap/test/demo1/abo ut-pat#" xmlns:bio="http://www.w3.org/2000/10/swap/test/demo1/ biology#" xmlns:per="http://www.w3.org/2000/10/swap/test/demo1/f riends-vocab#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntaxns#"> Cont. <bio:Human rdf:about="#pat"> <per:name>Pat Smith</per:name> <per:name>Patrick Smith</per:name> <per:pet> <bio:Dog> <per:name>Rover</per:name> </bio:Dog> </per:pet> </bio:Human> </rdf:RDF> END