Skip to content

Instantly share code, notes, and snippets.

Classes, inheritance, and properties are, of course, known in other fields of computing, for example, in object-oriented programming. But while there are many similarities, there are differences, too. In object-oriented program- ming, an object class defines the properties that apply to it. To add new properties to a class means to modify the class.

However, in RDFS, properties are defined globally, that is, they are not encapsulated as attributes in class definitions. It is possible to define new properties that apply to an existing class without changing that class.

On one hand, this is a powerful mechanism with far-reaching conse- quences: we may use classes defined by others and adapt them to our re- quirements through new properties. On the other hand, this handling of properties deviates from the standard approach that has emerged in the area of modeling and object-oriented programming. It is another idiosyncratic feature of RDF/RDFS.

http://www.ics.forth.gr/isl/swprimer/

In Linked Data, properties are, just as everything else, identified by IRIs and thus have global scope which implies that they have independent semantics. In contrast, properties in data models as used in common programming languages are class-dependent. Their semantics depend on the class they belong to. In data models classes are typically described by the properties they expose whereas in Linked Data properties define to which classes they belong. If no class is specified, it is assumed that a property may apply to every class.

These differences have interesting consequences. For example, the commonly asked question of which properties can be applied to an instance of a specific class can typically not be answered for Linked Data. Strictly speaking, any property which is not explicitly forbidden could be applied. This stems from the fact that Linked Data works under an open-world assumption whereas data models used by programmers typically work under a closed-world assumption. The difference is that when

@ericmoritz
ericmoritz / .gitignore
Last active August 29, 2015 13:56
Sample RDF data
*~
.venv/
build/
src/
echo "recent_rdf_store.rq returns nothing: "; arq --data=index.ttl --query=recent_rdf_store.rq
echo
echo "recent.rq returns two rows in arq: "; arq --data=index.ttl --query=recent.rq
<html
xmlns:gannett="http://api.gannett.com/vocab/core#">
<head>
<link about="." rel="gannett:section" href="/news/" />
<link about="." rel="gannett:section" href="/life/" />
<title about="." property="schema:name">USA Today</title>
</head>
<body>
<div about="/news/">
<a href="/news/">
@ericmoritz
ericmoritz / .gitignore
Last active August 29, 2015 13:56
memesearch
.venv/
*~
*.pyc
@ericmoritz
ericmoritz / Makefile
Last active August 29, 2015 13:57
Weight Matrix using RDF
results.txt:
arq --query weighted-matrix.rq --data weighted-matrix.ttl --data diagram-software.ttl > results.txt
clean:
rm results.txt
for node in dev/*/etc/riak.conf; do
cat $node \
| sed "s/storage_backend = bitcask/storage_backend = leveldb/" \
| sed "s/riak_control = off/riak_control = on/" \
| sed "s/search = off/search = on/" > ${node}.1 \
mv ${node}.1 ${node};
done
from collections import Mapping, Iterator
from rdflib import URIRef, Graph, Literal, Namespace
import pystache
from pystache.context import ContextStack
import re
RDFS = Namespace(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
class GraphDict(Mapping, dict):