【问题标题】:Get the @language tag from a SPARQL request从 SPARQL 请求中获取 @language 标记
【发布时间】:2017-11-26 09:04:19
【问题描述】:

我使用http://dbpedia.org/sparql 来做这个请求:

PREFIX res: <http://dbpedia.org/resource/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?trad
where{
res:Apple
rdfs:label ?trad
}

返回以下结果:

如何在单独的列中获取语言标签(@ar、@es、@fr)?

我在 w3.org 上看到了一些可能有帮助的东西:

有什么想法吗?

【问题讨论】:

    标签: sparql dbpedia


    【解决方案1】:

    SPARQL 文档包含有关 SPARQL 的所有内容,因此,它始终是最适合深入研究的来源。

    在你的情况下,关于the language of an RDF term 的部分很有用。

    PREFIX res: <http://dbpedia.org/resource/>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    SELECT ?trad (lang(?trad) as ?lang) WHERE {
      res:Apple rdfs:label ?trad
    }
    

    【讨论】:

      【解决方案2】:

      要将“@fr”、“@es”和“@ar”语言标记值组合到一个表中,并使用分隔列,请尝试使用 SPARQL UNION 关键字和 FILTER 以及每个变量上的语言函数:

      PREFIX dbr: <http://dbpedia.org/resource/> 
      PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
      
      SELECT ?french ?spanish ?arabic
      
      where{ { dbr:Apple rdfs:label ?french  FILTER ( lang(?french) = "fr" ) }
      UNION
      { dbr:Apple rdfs:label ?spanish   FILTER ( lang(?spanish) = "es" ) }
      UNION
      { dbr:Apple rdfs:label ?arabic   FILTER ( lang(?arabic) = "ar" ) }}
      

      【讨论】:

        猜你喜欢
        • 2021-03-22
        • 2021-02-09
        • 2012-01-11
        • 1970-01-01
        • 2019-08-10
        • 2018-05-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多