繁体   English   中英

如何使用sparql将类添加到本体中的特定类?

[英]How to add classes to a specific class in an ontology with sparql?

我们有一个关于sparql的问题,因为我们正在尝试将dbpedia中的类链接到Protégé中的本体。 我们的门生关于宠物。 我们正在尝试使用以下查询从dbpedia中获取所有犬种,并将它们作为Protégé中“狗”类的子类实现。

该查询的结果是,所有犬种都成为我们本体中的常规类,但我们希望它成为“狗”类的子类。

非常感谢!

    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)
      }
    } 

资源通过属性dct:subject而不是rdf:type (在Turtle中又称为a )连接到DBpedia类别。 也就是说,从

?x a dbc:Dog_breeds .

?x dct:subject dbc:Dog_breeds .

应该可以工作(对以后可能出现的其他问题取模)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM