3

我正在尝试查询所有机场及其 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

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

我究竟做错了什么?

编辑 - 找到解决方案:

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

4

1 回答 1

0

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 结果

数据稍微好一些,但仍然有一些奇怪的结果,例如:

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

为了尝试几种不同的方法,我还决定尝试按?airportand分组?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 结果

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

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 结果

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”,你不会在那里找到它。

于 2013-07-20T02:27:39.633 回答