2

I want to check if two DBpedia nodes have a path using;

  • dct:subject and skos:broader properties
  • without specifying properties

For instance consider the two DBpedia nodes http://dbpedia.org/resource/Cat and http://dbpedia.org/resource/Dog. I tried to use the following wildcard query to do it.

ASK {
  <http://dbpedia.org/resource/Cat> ((<>|!<>)|^(<>|!<>))* <http://dbpedia.org/resource/Dog> 
}

However, I get a memory error. I am wondering if there is a more suitable way of doing this in sparql.

I am happy to provide more details if needed.

1

Your question shows <> which is not a valid property or wildcard.

You cannot use property variables (wildcards) in property paths.

So you need to understand the structure of how dct:subject and skos:broader are used, and exploit that. I happen to know that

  • dct:subject links pages to categories
  • skos:broader makes the category hierarchy

I should warn you that the wikipedia category hierarchy is vast and diverging. Eg see "Domain-specific modeling: Towards a Food and Drink Gazetteer" (Slides, pdf, published).

You don't want to use skos:broader*, instead use Transitive reasoning and skos:broaderTransitive (eg get our GraphDB Free edition). So you can try

select * {
  ?cat skos:subject/skos:broaderTransitive ?x.
  ?dog skos:subject/skos:broaderTransitive ?x.
}

but because of the vast and diverging structure, this will take a LOT of time and return lots of cats, many of them barely relevant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.