查询适用于Wikidata查询服务,但不适用于Apache Jena复制

编程入门 行业动态 更新时间:2024-10-23 11:18:02
本文介绍了查询适用于Wikidata查询服务,但不适用于Apache Jena复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下查询是我的问题仅获取英语属性值.在Wikidata查询服务上使用时试试吧!它将显示像澳大利亚这样的国家/地区的简称-> AUS和奥地利-> AUT复刻.在我的本地Wikidata副本上运行相同的查询 基于Apache Jena Fuseki创建的,shortName列保持空白(请参见下面的屏幕截图). >

造成这种差异的原因是什么?如何修改查询使其也可以与Apache Jena Fuseki一起使用?

# get a list countries with the corresponding ISO code PREFIX rdfs: <www.w3/2000/01/rdf-schema#> PREFIX wd: <www.wikidata/entity/> PREFIX wdt: <www.wikidata/prop/direct/> PREFIX wikibase: <wikiba.se/ontology#> PREFIX p: <www.wikidata/prop/> PREFIX ps: <www.wikidata/prop/statement/> PREFIX pq: <www.wikidata/prop/qualifier/> SELECT ?country ?countryLabel ?shortName (MAX(?pop) as ?population) ?coord ?isocode WHERE { # instance of country ?country wdt:P31 wd:Q3624078. OPTIONAL { ?country rdfs:label ?countryLabel filter (lang(?countryLabel) = "en"). } OPTIONAL { ?country p:P1813 ?shortNameStmt. # get the short name statement ?shortNameStmt ps:P1813 ?shortName # the the short name value from the statement filter (lang(?shortName) = "en") # filter for English short names only filter not exists {?shortNameStmt pq:P31 wd:Q28840786} # ignore flags (aka emojis) } OPTIONAL { # get the population # www.wikidata/wiki/Property:P1082 ?country wdt:P1082 ?pop. } # get the iso countryCode { ?country wdt:P297 ?isocode }. # get the coordinate OPTIONAL { ?country wdt:P625 ?coord }. } GROUP BY ?country ?countryLabel ?shortName ?population ?coord ?isocode ORDER BY ?countryLabel

解决方案

@UninformedUser的测试查询:

PREFIX rdfs: <www.w3/2000/01/rdf-schema#> PREFIX wd: <www.wikidata/entity/> PREFIX wdt: <www.wikidata/prop/direct/> PREFIX wikibase: <wikiba.se/ontology#> PREFIX p: <www.wikidata/prop/> PREFIX ps: <www.wikidata/prop/statement/> PREFIX pq: <www.wikidata/prop/qualifier/> SELECT ?country ?shortNameStmt ?shortName WHERE { VALUES ?country {wd:Q40} ?country wdt:P31 wd:Q3624078. OPTIONAL { ?country p:P1813 ?shortNameStmt. ?shortNameStmt ps:P1813 ?shortName filter (lang(?shortName) = "en") filter not exists {?shortNameStmt pq:P31 wd:Q28840786} } }

在基于事实的wikidata导入上进行最新全部导入时,未给出结果.完整查询也是如此.还是要知道为什么查询不能与真实数据集一起工作.

The query below is the accepted answer for my question Getting only english property value. When used on the Wikidata Query service try it! it will show shortNames for countries like Australia -> AUS and Austria -> AUT as requeted. Running the same query on my local Wikidata copy created a few weeks ago based on Apache Jena Fuseki the shortName column stays empty (see screenshot below).

What is the reason for the difference and how could the query be modified to also work with Apache Jena Fuseki?

# get a list countries with the corresponding ISO code PREFIX rdfs: <www.w3/2000/01/rdf-schema#> PREFIX wd: <www.wikidata/entity/> PREFIX wdt: <www.wikidata/prop/direct/> PREFIX wikibase: <wikiba.se/ontology#> PREFIX p: <www.wikidata/prop/> PREFIX ps: <www.wikidata/prop/statement/> PREFIX pq: <www.wikidata/prop/qualifier/> SELECT ?country ?countryLabel ?shortName (MAX(?pop) as ?population) ?coord ?isocode WHERE { # instance of country ?country wdt:P31 wd:Q3624078. OPTIONAL { ?country rdfs:label ?countryLabel filter (lang(?countryLabel) = "en"). } OPTIONAL { ?country p:P1813 ?shortNameStmt. # get the short name statement ?shortNameStmt ps:P1813 ?shortName # the the short name value from the statement filter (lang(?shortName) = "en") # filter for English short names only filter not exists {?shortNameStmt pq:P31 wd:Q28840786} # ignore flags (aka emojis) } OPTIONAL { # get the population # www.wikidata/wiki/Property:P1082 ?country wdt:P1082 ?pop. } # get the iso countryCode { ?country wdt:P297 ?isocode }. # get the coordinate OPTIONAL { ?country wdt:P625 ?coord }. } GROUP BY ?country ?countryLabel ?shortName ?population ?coord ?isocode ORDER BY ?countryLabel

解决方案

@UninformedUser's test query:

PREFIX rdfs: <www.w3/2000/01/rdf-schema#> PREFIX wd: <www.wikidata/entity/> PREFIX wdt: <www.wikidata/prop/direct/> PREFIX wikibase: <wikiba.se/ontology#> PREFIX p: <www.wikidata/prop/> PREFIX ps: <www.wikidata/prop/statement/> PREFIX pq: <www.wikidata/prop/qualifier/> SELECT ?country ?shortNameStmt ?shortName WHERE { VALUES ?country {wd:Q40} ?country wdt:P31 wd:Q3624078. OPTIONAL { ?country p:P1813 ?shortNameStmt. ?shortNameStmt ps:P1813 ?shortName filter (lang(?shortName) = "en") filter not exists {?shortNameStmt pq:P31 wd:Q28840786} } }

Did not give a result on the truthy-based import of wikidata while it worked on the latest-all import. The same holds true for the full query. Still it would be good to know why the query does not work with the truthy dataset.

更多推荐

查询适用于Wikidata查询服务,但不适用于Apache Jena复制

本文发布于:2023-10-24 14:43:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524208.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   但不   Jena   Wikidata   Apache

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!