我正在尝试查询所有机场及其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
除了名字中都有“王子”外,他们似乎没有任何共同点。单击该资源也表明与他们已分配的名称无关。
我做错了什么?
编辑 - 找到解决方案:
删除“按机场排序”或将其更改为“按订单排序?iata”可解决此问题。
答案 0 :(得分:0)
DBpedia本体(dbpedia-owl
)数据往往比旧的信息框数据(dbprop
)更清晰,所以我想您可能想要使用使用{{1}的查询} properties:
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
为了尝试一些不同的方法,我还决定尝试按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
然而,如果我们按名称分组,并选择名称并计算具有给定名称的机场数量,我们会全面获得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
这真的很奇怪。看起来你的查询没有任何问题,但是在DBpedia上发生了一些奇怪的事情。您可以查看其中一些奇怪的条目,DBpedia将显示的数据与这些结果不匹配。例如,原始查询的结果之一是
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
但是如果您访问http://dbpedia.org/page/Prince_Mohammad_Bin_Abdulaziz_Airport并在页面中搜索“Albert”,那么您将无法找到它。