0

As I am using this query text to find out those skos:broader related concepts of the keyword: England.

select ?ChildNodes where 
{
<http://dbpedia.org/resource/Category:England> skos:broader ?ChildNodes
}

and I've got the result like this:

ChildNodes
http://dbpedia.org/resource/Category:Germanic_countries_and_territories
http://dbpedia.org/resource/Category:Great_Britain
http://dbpedia.org/resource/Category:Island_countries
http://dbpedia.org/resource/Category:Wikipedia_categories_named_after_countries
http://dbpedia.org/resource/Category:United_Kingdom_by_country

In order to build the concept hierarchy (tree), it is necessary for me to find out all the skos:broader relations of the result. Can any one let me know how to combine those SPARQL queries in one query? Thank you so much!!!

BBQ
  • 23
  • 4
  • I query through: http://dbpedia.org/sparql – BBQ Jun 30 '20 at 09:02
  • what is missing here? This are all direct relations, the result is correct – UninformedUser Jun 30 '20 at 09:09
  • Thank you for the comment. As I would like to find out all the skos:broader relations of the result. For example, the skos:broader relations of Germanic_countries_and_territories, Great_Britain, Island_countries, Wikipedia_categories_named_after_countries and United_Kingdom_by_country. How can I combine those SPARQL queries in one query? Thank you so much!!! – BBQ Jun 30 '20 at 10:34
  • what means "all"? There are just five or not? if you mean the transitive ones, do `skos:broader*` – UninformedUser Jun 30 '20 at 10:37
  • "All" means all of five skos:broader relations of the result. – BBQ Jun 30 '20 at 10:40
  • For example, I firstly use this query text to find out those skos:broader related concepts of the keyword: England. `select ?ChildNodes where { skos:broader ?ChildNodes } ` Then, from the result, I would like to find out the skos:broader relations of Germanic_countries_and_territories. I will use this query text: `select ?GrandchildNodes where { skos:broader ?GrandchildNodes } ` The problem is how can I combine them into one query. Hope that it is easy for you to understand. – BBQ Jun 30 '20 at 10:41
  • you can use `UNION` for example: `select * where { { skos:broader ?ChildNodes } UNION { skos:broader/skos:broader ?GrandchildNodes}}` - not sure if this is what you want – UninformedUser Jun 30 '20 at 10:48
  • Thank you so much! It is exactly what I am looking for. I will keep trying to familiar with the sparql query. – BBQ Jun 30 '20 at 10:52
  • I got a little bit confused that what is the meaning of `skos:broader/skos:broader`. Is it same as skos:broader? – BBQ Jun 30 '20 at 10:56
  • It's just a path of length 2 of two `skos:broader` egdes – UninformedUser Jun 30 '20 at 16:36
  • Thank you so much @UninformedUser . I still got some questions that you may help. When I query for the skos:narrower relation, for example, `select ?ParentNodes where { skos:narrower ?ParentNodes }`,the result is empty. However, I look at the skos:concept of England [link]http://dbpedia.org/page/Category:England , the property:"is skos:broader of" does exist. isn't it means skos:narrower relation? Thank you so much! – BBQ Jul 08 '20 at 07:08
  • no, it does not. The property to use is still `skos:broader`. "is of" in DBpedia web view of a resource means, subject and object position are switched. That means the RDF triple in the dataset is `o skos:broader s` when looking at the web page of `s`. In your case, `select ?childNodes where { ?childNodes skos:broader }` would do the trick. Indeed, I understand your reasoning, `skos:narrower` is indeed the inverse of `skos:broader`. But this needs a reasoner behind which is not the case in Virtuoso with out enabling some ruleset. – UninformedUser Jul 08 '20 at 07:11
  • Thanks again for the immediately reply. Your answer is very easy to understand. is that means the skos:concept of Endland does not exist any skos:narrower relation? If it exist any skos:narrower relation with other concept, how can I find them out? Can you let me know more about the "reasoner"? Thank you so much – BBQ Jul 08 '20 at 07:46
  • there is no need for a `skos:narrower` relation here is it is defined is the inverse of `skos:broader`. Obviously, adding both to the dataset would be redundant and double the size of the triples. A reasoner does make use of schema information, for Virtuoso as backend triple store of Dbpedia, it would need to register such a rule, which is not possible for you. – UninformedUser Jul 08 '20 at 08:29
  • Just do `select ?childNodes where { ?childNodes skos:broader }` and you'll get what you need. Or do `select ?childNodes where { skos:broader^ ?childNodes }` which is a SPARQL property path in inverse direction. – UninformedUser Jul 08 '20 at 08:29
  • Thank you so much for the valuable advise. As I am going to build the concept hierarchy (tree) by using SPARQL query. Now, I am able to build some concept tree will semantic broader relations. For some concept which does no exist skos:broader relation, the inverse of skos:broader relations may help the concept map building. For next stage, I am going to write the query for the automatically SPARQL query against one keyword. Do you think which is achievable? I am willing to hearing from you. Thank you so much!! speechless! – BBQ Jul 08 '20 at 11:45
  • @UninformedUser - Note that your `select ?childNodes where { skos:broader^ ?childNodes }` is incorrect -- the carat (`^`) must precede the property to invert it; i.e., `skos:broader^` should be `^skos:broader`. BBQ - You may benefit by reviewing the [SPARQL 1.1 Property Path documentation](https://www.w3.org/TR/sparql11-query/#propertypaths). – TallTed Oct 08 '20 at 20:45
  • Thank you very much for your suggesetion! @TallTed – BBQ Oct 09 '20 at 03:40

1 Answers1

0

If I understand correctly, you need to find the broader concepts for each of the five results in the resultset. If this is the case, your query should be like this:

SELECT ?ChildNodes ?ChildBroader WHERE {
   <http://dbpedia.org/resource/Category:England> skos:broader ?ChildNodes .
   ?ChildNodes skos:broader ?ChildBroader .
}

Furthermore, by using SPARQL property paths you can traverse the graph at an arbitrary level.

Stratos K
  • 341
  • 2
  • 14