【问题标题】:Semantic web, datatypes and sparql. (Is the return type arbitrarily)语义网、数据类型和 sparql。 (返回类型是否任意)
【发布时间】:2013-06-18 16:44:02
【问题描述】:

我发现语义网是动态类型的!例如,我一直在查询生日,直到现在我才找到xsd:Integers。但是,现在我在查询其他人时收到了xsd:date。从静态类型语言中使用时,您如何处理此问题?

【问题讨论】:

    标签: sparql semantic-web dbpedia


    【解决方案1】:

    根据 DBpedia wiki 中的 4.3 Infobox Data 部分,使用 dbpprop 命名空间 (http://dbpedia.org/property/) 中的属性的三元组更脏:

    因此,只有在您的应用程序需要完全覆盖所有 Wikipeda 属性并且您准备好接受相对嘈杂的数据时,您才应该使用 infobox 数据集。

    您将使用来自 dbpedia-owl (http://dbpedia.org/ontology/) 命名空间的属性获得更加一致的数据:

    信息框本体中的实例数据比信息框数据集更清晰、结构更好

    例如,如果您使用 dbprop:dateOfBirth 获取 20 个生日,您将获得整数和日期:

    SELECT distinct ?date WHERE { 
      ?x dbpprop:dateOfBirth ?date 
    }
    LIMIT 10
    

    SPARQL results

    date
    "1908"^^<http://www.w3.org/2001/XMLSchema#int>
    1946-03-14
    1951-06-15
    "1984"^^<http://www.w3.org/2001/XMLSchema#int>
    1878-11-09
    "24"^^<http://www.w3.org/2001/XMLSchema#int>
    "21"^^<http://www.w3.org/2001/XMLSchema#int>
    "2"^^<http://www.w3.org/2001/XMLSchema#int>
    "14"^^<http://www.w3.org/2001/XMLSchema#int>
    1922-02-10
    

    使用dbpedia-owl:birthDate 可以得到更一致的结果:

    SELECT distinct ?date WHERE { 
      ?x dbpedia-owl:birthDate ?date 
    }
    LIMIT 10
    

    SPARQL results

    date
    0001-01-01
    0001-03-12
    0005-02-27
    0012-08-31
    0012-12-07
    0015-09-24
    0016-09-16
    0019-05-26
    0019-11-25
    0030-11-08
    

    也就是说,数据中仍然存在一些噪音。例如,下面的查询告诉我们dbpedia-owl:birthDate 的对象有哪些数据类型,以及对于每种类型,dbpedia-owl:birthDate 拥有该类型对象的次数,以及该类型的示例对象显示为dbpedia-owl:birthDate 的对象。

    SELECT ?datetype (COUNT(?date) as ?numberOfType ) (SAMPLE(?date) as ?exampleDate )WHERE { 
      [] dbpedia-owl:birthDate ?date .
      BIND ( datatype( ?date ) as ?datetype )
    }
    GROUP BY ?datetype
    ORDER BY DESC(?numberOfType)
    

    SPARQL results

    datetype                                    numberOfType  exampleDate
    http://www.w3.org/2001/XMLSchema#date       608771        0001-01-01
    http://www.w3.org/2001/XMLSchema#gMonthDay    1185        "--02-29"^^<http://www.w3.org/2001/XMLSchema#gMonthDay>
    http://www.w3.org/2001/XMLSchema#string        246        "--01-01"^^<http://www.w3.org/2001/XMLSchema#gMonthDay>
    

    大部分日期是xsd:dates。我不确定为什么 xsd:gMonthDay 会出现 xsd:string 的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-18
      • 1970-01-01
      • 2020-12-05
      • 2020-07-05
      • 2022-01-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多