Using standard ontologies with as(...)
As I previously said, one of the advantage of using an RDF store is
that you're offered with a bunch of standard “ontologies”, that are
standard ways to do some common things (sounds nice, doesn't it?).
Those things are related to managing relationships among things.
A common need that clearly emerges when you extensively use href="http://weblogs.java.net/blog/fabriziogiudici/archive/2009/11/22/when-rdf-store-meets-netbeans-lookup">the
as(...) pattern that I've explained in my previous blog is
how to specify that two distinct object are indeed referring to the
same concept. Adding some more examples to href="http://weblogs.java.net/blog/fabriziogiudici/archive/2009/11/22/when-rdf-store-meets-netbeans-lookup">my
previous post, I could write things such as:
Employee employee =
department = employee.getDepartment();
observation = observationSet.createObservation().
item(flamingo, Cardinality.rangeOf(100, 150)).
models behaviours related to the life in a corporate, while style="font-family: monospace;">Person and style="font-family: monospace;">AccountHolder
are behaviours common to many other kind of people; in the last example
you can see as I can reuse Employee
with my href="http://weblogs.java.net/blog/2009/04/29/observation-api-hey-its-not-observable-pattern">Observation
API, to model the fact that employees with the birdwatching
hobby can make bird observations.
In my previous post I only focused to the API aspect, without giving
any detail about how to persistently store in RDF the binding
relationship among an Employee,
and an Observer.
In fact, one would expect that these relationships are
dynamic and can be created and destroyed at runtime.
Another common problem that emerges in many object collections is
the tree-shaped hierarchy. For instance, if you have to model
a taxonomy of birds or a
collection of geographic entities you face with the need of
representing a tree-shaped hierarchic structure. href="http://weblogs.java.net/blog/2009/02/02/bluemarine-went-semantic">Birds
have phylum, class, order, family, genus, species;
geographic entities have country, region, province, municipality,
Two standard ontologies help us. For the former problem we can use href="http://www.w3.org/TR/owl-features/">OWL; for
the latter SKOS.
stuff related to semantic technologies is often much simpler than it
appears at first. If you google for OWL or SKOS you're likely to hit
the W3C official documents, which offer tons of information about their
specification stage etc... but you need a bit of patience to find some
simple example that demonstrates how they can be used - and how they
are useful. Maybe
this is a factor that reduces the spread of the technology? style="font-style: italic;"> The best online introduction
about SKOS I've found so far is unfortunately in style="font-style: italic;"
href="http://www.iskoi.org/doc/skos.htm">italian style="font-style: italic;">. Things are much
better with books such as style="font-style: italic;" href="http://workingontologist.org/">“Semantic
web for the working ontologist” style="font-style: italic;">, that literaly opened my mind,
but for sure simpler and more readable online resources would help.
For my needs, OWL defines a concept named “Thing” and a statement
“is-same-as”. This is a reasonably simple concept as it says that two
things are semantically equivalent, that is all the property and
statements of the former also hold for the latter and vice-versa.
In pseudo code with the as(...) pattern I can write:
Employee employee =
Person person = new
so later I can query the relationship:
Employee employee =
SKOS defines a concept named “(SKOS)Concept” and two statements href="http://www.w3.org/TR/skos-reference/skos.html#narrower">“is-a-narrower-of”
We can interpret “narrower” as “specialization” and “broader” as
“generalization”. So, for birds “species” is a narrower (=
specialization) of “genus” and “province” is a narrower of “region”. Of
course you can read in in the reverse way: genus is a broader (=
generalization) of species and region is a broader of province.
I think that things are much simpler if we look at some pseudo-code:
sausalito = new GeoLocation();
marinCounty = new GeoLocation();
california = new GeoLocation();
GeoLocation usa =
And later, for instance:
As usual, in my code OWLThing
are simple facades on href="http://weblogs.java.net/blog/fabriziogiudici/archive/2009/10/26/elmo-semantic-entity-manager">Elmo,
which provides the proper generation and query of RDF statements.
I should be able to present soon a more comprehensive example,
based on one of the APIs of forceTen,
the GeoLocation API. In fact, yesterday it seems I was able to perform
a good bunch of refactorings that moved it into a reasonable state.