【问题标题】:How to add classes to a specific class in an ontology with sparql?如何使用 sparql 将类添加到本体中的特定类?
【发布时间】:2016-10-26 11:13:10
【问题描述】:

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

这个查询的结果是所有的狗品种都成为我们本体的普通类,但我们希望它成为“狗”类的子类。

非常感谢!

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

【问题讨论】:

  • 如果您需要它们成为某事物的子类,那么添加 rdfs:subClassOf 三元组不是要走的路吗?
  • @JoshuaTaylor 对,这是更明显和正式的方式。但是这里使用了 DBpedia 类别dbc:Dog_breeds,这也应该没问题——唯一需要考虑的是必须使用dct:subject 作为谓词而不是rdf:type。此外,这意味着这些通常是 DBpedia 中的实例而不是类,但这是另一个需要考虑的问题。

标签: class sparql subclass dbpedia protege


【解决方案1】:

资源通过属性dct:subject 而不是rdf:type(在Turtle 中又名a)连接到DBpedia 类别。这意味着,将三重模式从

?x a dbc:Dog_breeds .

?x dct:subject dbc:Dog_breeds .

应该有效(模数之后确实可能出现的其他问题)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-25
    • 2012-04-06
    • 2012-02-14
    • 2019-01-24
    • 2019-07-02
    • 1970-01-01
    • 2014-08-15
    • 1970-01-01
    相关资源
    最近更新 更多