[英]How to add classes to a specific class in an ontology with sparql?
We have a question about sparql, because we're trying to link classes from dbpedia to our ontology in Protégé. 我们有一个关于sparql的问题,因为我们正在尝试将dbpedia中的类链接到Protégé中的本体。 Our protégé is about pets.
我们的门生关于宠物。 We're trying with the query below to get all the dog breeds from dbpedia and implement them as a subclass to our class 'Dog' in Protégé.
我们正在尝试使用以下查询从dbpedia中获取所有犬种,并将它们作为Protégé中“狗”类的子类实现。
What happens with this query is that all the dog breeds become normal classes our ontology, but we want it to be subclasses of the class 'Dog'. 该查询的结果是,所有犬种都成为我们本体中的常规类,但我们希望它成为“狗”类的子类。
Thanks a lot! 非常感谢!
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX umbelrc: <http://umbel.org/umbel/rc/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX ex: <http://data.kingcounty.cov/resource/yaai-7rfk/>
PREFIX dbc: <http://dbpedia.org/resource/Category:>
CONSTRUCT {
?x a owl:Class .
?x owl:equivalentClass [
rdf:type owl:Restriction ;
owl:onProperty ex:animal_type ;
owl:hasValue ?xls ;
] .
} WHERE {
SELECT ?x ?xls WHERE {
?x a dbc:Dog_breeds .
?x rdfs:label ?xl .
FILTER(lang(?xl) = 'en')
BIND(str(?xl) as ?xls)
}
}
Resources are connected to a DBpedia category by the property dct:subject
and not rdf:type
(aka a
in Turtle). 资源通过属性
dct:subject
而不是rdf:type
(在Turtle中又称为a
)连接到DBpedia类别。 that means, change the triple pattern from 也就是说,从
?x a dbc:Dog_breeds .
to 至
?x dct:subject dbc:Dog_breeds .
should work (modulo other issues that might arise afterwards indeed). 应该可以工作(对以后可能出现的其他问题取模)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.