我试图查询所有机场及其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执行它看上去很好,但是有一些奇怪的街区,机场被分配了错误的名称,例如:
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除了以他们的名义拥有“王子”之外,他们似乎没有什么共同之处。单击该资源还表明与所分配的名称无关。
我做错了什么?
编辑-找到的解决方案:
删除“按机场订购”或将其更改为“由国际航空运输协会订购”解决了问题。
发布于 2013-07-20 02:27:39
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 ?airportSPARQL结果
数据稍好一些,但仍然有一些奇怪的结果,如:
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 ?airportSPARQL结果
这会得到不同的结果,但同样奇怪的结果,例如:
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 ?nameSPARQL结果
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但是,如果您访问机场并在页面中搜索"Albert",您就不会在那里找到它。
https://stackoverflow.com/questions/17751094
复制相似问题