且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何通过Sparql查询在耶拿推理

更新时间:2023-01-10 08:34:22

您需要询问属于Tag子类的事物.因此,类似

You need to ask for things that are subclasses of Tag. Thus, something like

?class rdfs:subClassOf* :Tag

*表示您需要匹配0次或更多次出现的rdfs:subClassOf的路径,因此?class可以是Tag或Tag的子类,或Tag的子类的子类,等等.完整的工作查询将是:

The * means you need to match a path of 0 or more occurrences of rdfs:subClassOf, so ?class can be Tag, or a subclass of Tag, or or subclass of a subclass of Tag, etc. A complete working query would be:

prefix :      <http://www.semanticweb.org/man/ontologies/2014/5/untitled-ontology-11#> 
prefix owl:   <http://www.w3.org/2002/07/owl#> 
prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> 

select distinct ?subject where {
   ?subject owl:equivalentClass ?restriction .
   ?restriction owl:onProperty :hasTags .
   ?restriction ?restrictType ?class .
   ?class rdfs:subClassOf* :Tag 
}

-------------------------------------------------------------------------------------------
| subject                                                                                 |
===========================================================================================
| :Java_programming                                                                       |
| <http://www.semanticweb.org/man/ontologies/2014/5/untitled-ontology-11#C++_programming> |
| :System_Programming                                                                     |
-------------------------------------------------------------------------------------------