I'm trying to generalize 2 or more resources to 1 "common denominator". For example, let's say I have 2 or more skos:Concepts and I want to find a common skos:broaderTransitive concept that these concepts share. Say I have this dataset:

@prefix ex: <http://example.com/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .

ex:concept1 skos:broaderTransitive ex:concept3 .
ex:concept2 skos:broaderTransitive ex:concept3 .
ex:concept3 skos:broaderTransitive ex:concept6 .
ex:concept4 skos:broaderTransitive ex:concept5 .
ex:concept5 skos:broaderTransitive ex:concept6 .

I want to find the common broader concept for ex:concept1 and ex:concept4, which should give me ex:concept6.

I have implemented this in SPARQL by using OpenLink's Virtuoso transitivity extension:

PREFIX ex: <http://example.com/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?commonBroader
  ?concept1 skos:broaderTransitive ?commonBroader OPTION (transitive, t_in(?concept1), t_out(?commonBroader), t_step("step_no") as ?dist1) .
  FILTER (?concept1 = ex:concept1)
  ?concept4 skos:broaderTransitive ?commonBroader OPTION (transitive, t_in(?concept4), t_out(?commonBroader), t_step("step_no") as ?dist2) .
  FILTER (?concept4 = ex:concept4)
ORDER BY ASC(?dist1 + ?dist2)

Given ex:concept1 and ex:concept4 in the FILTER clauses, it correctly returns ex:concept6. However, I think this solution is far from ideal. For instance, I had to use the path length (using t_step() and then ORDER BY and LIMIT 1) instead of t_shortest_only, which caused to the query to return empty set.

What could be a better option how to implement this using Virtuoso's transitivity extensions, or, if there's any chance of implementing the query in standard SPARQL (1.1)? Thanks in advance for sharing your thoughts on this.

asked 12 Jan '13, 05:28

jindrichm's gravatar image

accept rate: 30%

edited 12 Jan '13, 14:08

Not sure it helps you much, but in SPARQL 1.1 this can be done with the following query:

{   ex:concept1 skos:broaderTransitive* ?commonBroader .
    ex:concept4 skos:broaderTransitive* ?commonBroader .

Pretty much the same principle, I believe, but a much nicer syntax. And there is just the single result.

permanent link

answered 12 Jan '13, 17:01

scotthenninger's gravatar image

scotthenninger ♦
accept rate: 17%


Definitely much clearer syntax. I've tested your query with ARQ (2.9.4), with which it works fine. Unfortunately, with Virtuoso one has to resort to their specific syntax. Hopefully they will catch up with others, implementing SPARQL 1.1 once it becomes a standard.

(13 Jan '13, 02:11) jindrichm jindrichm's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Jan '13, 05:28

question was seen: 1,191 times

last updated: 05 Mar '13, 11:34