Showing posts with label SPARQL. Show all posts
Showing posts with label SPARQL. Show all posts

Wednesday, 2 December 2009

SPARQL - extension




I know that there is a working group that is looking for extending the current SPARQL specification/protocol. There are also some discussions outside the working group that outlines requirements for such an extension.

As a contribution to these efforts, in this post I want to start outlining things ( queries ) that are not possible to write using SPARQL in its current state. Requirement of such query syntax and support stems from demands of practical Semantic Web development work. Here are some examples. I will appreciate your comments if I am incorrectly assuming that these sort of queries are not possible to write.

1. A query to verify the cardinality of property values.
For example, in DBPedia, a Band (<http://dbpedia.org/ontology/Band>) has property <http://dbpedia.org/ontology/genre> with no cardinality restrictions (i.e. Band can have any number of genres).

Using sparql one can not extract Bands which has more than x number of genres?

The following SPARQL query is not possible to write and execute:

Select ?band
where
{
?band rdf:type <http://dbpedia.org/ontology/Band> .
FILTER (COUNT(?genre) > 3).
}

2. Support for negation. It is well known that SPARQL does not support negation. It is obvious that negation is an important feature to have, I will demonstrate the usefulness of negation using one scenario.

In DBPedia ontology, the classification hierarchy for "Organisation" is as follows:


If you are mapping your ontology to DBPedia's and if you have a slightly different hierarchy where "SportsTeam" is not a subclass of "Organisation" then
in order to retrieve all the instances of Organisation class that are not "SportsTeam" you will need to use negation (ALL(Organisation)-ALL(SportsTeam)).

The alternative is cumbersome solution where the query will involve retrieving instances of "Organisation"subclasses except SportsTeam and then merging them. For example,

Regex support in CONSTRUCT queries:

One of the purposes of CONSTRUCT queries is to map ontologies and datasets. It will be quite useful to be able to specify regex based URI patterns as part of the CONSTRUCT queries. Particularly applicable where one wants to use the unique & human readbale identifiers from DBPedia. For example, it will be useful to have something like:

CONSTRUCT
{
<http://myurischeme/resource/"unique id from DBPedia URI"> rdf:type myOntology:myType.
}
WHERE
{
<http://dbpedia.org/resource/ABC> rdf:type <http://dbpedia.org/ontology/Person>
}

Thursday, 18 June 2009

Ontology mapping using SPARQL (Triples extraction from DBPedia)

I have been using SPARQL CONSTRUCT for ontology mapping. One of the problems, I have encountered during my work is, how do I get around BNode in the output graph, as BNode are ugly, not shareable (if thats right word!) and you can say not at all useful here. What you want in the target graph is a clear URI, as you might want to share this new URI with other graphs you extract from different source ontologies.

I stumbled on this post, which have similar conclusion. Somewhere in the post the author mentions that,

"it appears to be impossible to create new URIs for the resources in the target ontology - only bnodes can be created on the fly."

and they had to use some post-processing script to manage bnodes. I am still working on finding a workaround, if I can not then I will have to conclude the same.

Based on my findings, I will update this post soon....