如何通过 属性 的 class 筛选 SPARQL 查询
How to filter a SPARQL query by a property's class
是否可以通过其属性之一的 class 来查询过滤器 SPARQL 查询?
我有一个描述电影的ontology,我想展示所有在欧洲拍摄的电影。
当前的SPARQL查询如下:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX cinema: <http://example.com/ontologies/cinemachain#>
SELECT ?film ?location
WHERE {
?film rdf:type cinema:Film .
?film cinema:wasFilmedAt ?location .
FILTER(?location rdfs:subClassOf cinema:Europe) .
}
where 子句的前两行给出了所有电影及其位置的列表。我如何使用过滤器 return 我的结果,其中位置是 cinema:Europe 的子 class?
In this particular ontology, cinema:Europe is a subclass of cinema:Location. This is so that we can easily identify particular
locations by continent. For this filter, I want to find all films who
have a location which is a member of Europe. Do you know how I can do
this using SPARQL?
好的,命名约定有点不寻常,但我们可以使用它。您只需要要求 ?location 的类型是 Europe 的子类(包括 Europe 本身):
select ?film ?location where {
?film rdf:type cinema:Film ;
cinema:wasFilmedAt ?location .
?location rdf:type/rdfs:subClassOf* cinema:Europe .
}
是否可以通过其属性之一的 class 来查询过滤器 SPARQL 查询? 我有一个描述电影的ontology,我想展示所有在欧洲拍摄的电影。
当前的SPARQL查询如下:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX cinema: <http://example.com/ontologies/cinemachain#>
SELECT ?film ?location
WHERE {
?film rdf:type cinema:Film .
?film cinema:wasFilmedAt ?location .
FILTER(?location rdfs:subClassOf cinema:Europe) .
}
where 子句的前两行给出了所有电影及其位置的列表。我如何使用过滤器 return 我的结果,其中位置是 cinema:Europe 的子 class?
In this particular ontology, cinema:Europe is a subclass of cinema:Location. This is so that we can easily identify particular locations by continent. For this filter, I want to find all films who have a location which is a member of Europe. Do you know how I can do this using SPARQL?
好的,命名约定有点不寻常,但我们可以使用它。您只需要要求 ?location 的类型是 Europe 的子类(包括 Europe 本身):
select ?film ?location where {
?film rdf:type cinema:Film ;
cinema:wasFilmedAt ?location .
?location rdf:type/rdfs:subClassOf* cinema:Europe .
}