gpt4 book ai didi

dbpedia - DBPedia 的奇怪结果

转载 作者:行者123 更新时间:2023-12-02 14:50:04 28 4
gpt4 key购买 nike

我正在尝试查询所有机场及其 IATA 代码的列表:

PREFIX p: <http://dbpedia.org/property/>
PREFIX o: <http://dbpedia.org/ontology/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT DISTINCT ?airport ?iata ?name
WHERE {
?airport rdf:type o:Airport ;
p:iata ?iata ;
p:name ?name
}
ORDER by ?airport

Executing it看起来大部分都很好,但有一些奇怪的街区,机场被分配了错误的名称,例如:

http://dbpedia.org/resource/Prince_Abdul_Majeed_bin_Abdul_Aziz_Domestic_Airport  "ULH"@en   "Prince Abdul Majeed bin Abdul Aziz Airport"@en
http://dbpedia.org/resource/Prince_Albert_(Glass_Field)_Airport "YPA"@en "Prince Abdul Majeed bin Abdul Aziz Airport"@en
http://dbpedia.org/resource/Prince_George_Airport "YXS"@en "Prince Abdul Majeed bin Abdul Aziz Airport"@en
http://dbpedia.org/resource/Prince_Mohammad_Bin_Abdulaziz_Airport "MED"@en "Prince Abdul Majeed bin Abdul Aziz Airport"@en
http://dbpedia.org/resource/Prince_Rupert/Seal_Cove_Water_Airport "ZSW"@en "Prince Abdul Majeed bin Abdul Aziz Airport"@en
http://dbpedia.org/resource/Prince_Rupert_Airport "YPR"@en "Prince Abdul Majeed bin Abdul Aziz Airport"@en
http://dbpedia.org/resource/Prince_Said_Ibrahim_International_Airport "HAH"@en "Prince Abdul Majeed bin Abdul Aziz Airport"@en
http://dbpedia.org/resource/Princess_Juliana_International_Airport "SXM"@en "Prince Abdul Majeed bin Abdul Aziz Airport"@en

除了名字中都有“Prince”之外,他们似乎没有任何共同点。单击该资源也表明与为其分配的名称没有任何关系。

我做错了什么?

编辑 - 找到解决方案:

删除“ORDER by ?airport”或将其更改为“ORDER by ?iata”即可解决该问题。

最佳答案

DBpedia 本体 (dbpedia-owl) 数据往往比旧的信息框数据 (dbprop) 更干净,所以我认为您可能想要使用使用 dbpedia-owl 属性的查询:

SELECT ?airport ?iata ?name
WHERE {
?airport a dbpedia-owl:Airport ;
dbpedia-owl:iataLocationIdentifier ?iata ;
rdfs:label ?name .
FILTER langMatches( lang( ?name ), "EN" )
}
order by ?airport

SPARQL Results

数据有所好转,但仍然存在一些奇怪的结果,例如:

http://dbpedia.org/resource/Prince_Albert_(Glass_Field)_Airport "YPA"@en    "Prince Albert (Glass Field) Airport"@en
http://dbpedia.org/resource/Prince_George_Airport "YXS"@en "Prince Albert (Glass Field) Airport"@en
http://dbpedia.org/resource/Prince_Mohammad_Bin_Abdulaziz_Airport "MED"@en "Prince Albert (Glass Field) Airport"@en
http://dbpedia.org/resource/Prince_Rupert/Seal_Cove_Water_Airport "ZSW"@en "Prince Albert (Glass Field) Airport"@en
http://dbpedia.org/resource/Prince_Rupert_Airport "YPR"@en "Prince Albert (Glass Field) Airport"@en
http://dbpedia.org/resource/Prince_Said_Ibrahim_International_Airport "HAH"@en "Prince Albert (Glass Field) Airport"@en
http://dbpedia.org/resource/Princess_Juliana_International_Airport "SXM"@en "Prince Albert (Glass Field) Airport"@en
http://dbpedia.org/resource/Princeton_Airport_(New_Jersey) "PCT"@en "Prince Albert (Glass Field) Airport"@en

为了尝试几种不同的方法,我还决定尝试按 ?airport?iata 进行分组,然后对名称进行采样:

SELECT ?airport ?iata sample(?name)
WHERE {
?airport a dbpedia-owl:Airport ;
dbpedia-owl:iataLocationIdentifier ?iata ;
rdfs:label ?name .
FILTER langMatches( lang( ?name ), "EN" )
}
group by ?airport ?iata
order by ?airport

SPARQL Results

这会得到不同但同样奇怪的结果,例如:

http://dbpedia.org/resource/%22Solidarity%22_Szczecin-Goleni%C3%B3w_Airport "SZZ"@en    ""Solidarity" Szczecin-Goleniów Airport"@en
http://dbpedia.org/resource/%C3%81ngel_Albino_Corzo_International_Airport "TGZ"@en ""Solidarity" Szczecin-Goleniów Airport"@en
http://dbpedia.org/resource/%C3%84ngelholm-Helsingborg_Airport "AGH"@en ""Solidarity" Szczecin-Goleniów Airport"@en
http://dbpedia.org/resource/%C3%85lesund_Airport,_Vigra "AES"@en ""Solidarity" Szczecin-Goleniów Airport"@en
http://dbpedia.org/resource/%C3%85re_%C3%96stersund_Airport "OSD"@en ""Solidarity" Szczecin-Goleniów Airport"@en

但是,如果我们按名称分组,然后选择名称并计算具有给定名称的机场数量,我们会全面得到 1,但有些名称出现两次!

SELECT count(?airport) ?name
WHERE {
?airport a dbpedia-owl:Airport ;
dbpedia-owl:iataLocationIdentifier ?iata ;
rdfs:label ?name .
FILTER langMatches( lang( ?name ), "EN" )
}
group by ?name
order by ?name

SPARQL Results

1   "Abraham González International Airport"@en
1 "Abraham González International Airport"@en
...
1 "Prince Albert (Glass Field) Airport"@en
1 "Prince Albert (Glass Field) Airport"@en
1 "Prince Albert (Glass Field) Airport"@en
1 "Prince Albert (Glass Field) Airport"@en
1 "Prince Albert (Glass Field) Airport"@en
1 "Prince Albert (Glass Field) Airport"@en
1 "Prince Albert (Glass Field) Airport"@en
1 "Prince Albert (Glass Field) Airport"@en

这确实很奇怪。您的查询看起来没有任何问题,但 DBpedia 发生了一些奇怪的事情。您可以看一下其中一些奇怪的条目,DBpedia 将显示的数据与这些结果不匹配。例如,原始查询的结果之一是

http://dbpedia.org/resource/Prince_Mohammad_Bin_Abdulaziz_Airport   "MED"@en    "Prince Albert (Glass Field) Airport"@en

但是如果您访问http://dbpedia.org/page/Prince_Mohammad_Bin_Abdulaziz_Airport并在页面中搜索“Albert”,您不会在那里找到它。

关于dbpedia - DBPedia 的奇怪结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17751094/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com