使用SPARQL从DBpedia获取有关景点和兴趣点的数据

时间:2017-06-02 14:07:39

标签: sparql dbpedia

我不知道如何使用DBpedia或SPARQL。

您能否帮我找到DBpedia的景点和兴趣点数据列表。

其实我想要所有城市/国家的酒店和旅游景点,纬度,经度,景点名称,位置名称,城市,州,大陆等。

请使用“查询SPARQL”帮助我获取数据。

如果您有任何其他建议,请指导我..

1 个答案:

答案 0 :(得分:4)

这是端点:http://dbpedia.org/sparql/

获得叙利亚的所有酒店:

select * where {
?hotel a <http://dbpedia.org/ontology/Hotel> .
?hotel dbo:location dbr:Syria
}

这个答案只是为了让您了解如何查询DBPedia

更新

发表评论假设我想获得孟买市的所有旅游景点或兴趣点

你应该定义那些“旅游景点*是什么?在下面的查询中,我举了一个例子,假设旅游景点是博物馆,塔楼,公园,教堂,摩天大楼,

select ?thing ?type ?typeName where {

VALUES ?city {<http://dbpedia.org/resource/London>}

?thing dbo:location ?city.

optional 
{
?thing a ?type .
VALUES ?type {<http://dbpedia.org/ontology/Hotel>}
BIND( "Hotel" as ?typeName )
}

optional
{
?thing a ?type.
VALUES ?type {dbo:Museum}
BIND( "Museum" as ?typeName )
}
optional
{
?thing a ?type.
VALUES ?type {dbo:Pyramid}
BIND( "Pyramid" as ?typeName )
}

optional
{
?thing a ?type.
VALUES ?type {yago:Skyscraper104233124}
BIND( "Skyscraper" as ?typeName )
}

optional
{
?thing a ?type.
VALUES ?type {dbo:Park}
BIND( "Park" as ?typeName )
}

optional
{
?thing a ?type.
VALUES ?type {yago:Church103028079}
BIND( "Church" as ?typeName )
}

{
?thing a dbo:Place
}

filter (BOUND (?type))

}

如果你明白了,你可以扩展它

更新2

你想展示长,拉特和国家。你走了:

select ?thing ?type ?typeName ?long ?lat ?country where {

VALUES ?city {<http://dbpedia.org/resource/London>}

optional {
?city dbo:country ?country
}

?thing dbo:location ?city.

optional 
{
?thing a ?type .
VALUES ?type {<http://dbpedia.org/ontology/Hotel>}
BIND( "Hotel" as ?typeName )
}

optional
{
?thing a ?type.
VALUES ?type {dbo:Museum}
BIND( "Museum" as ?typeName )
}
optional
{
?thing a ?type.
VALUES ?type {dbo:Pyramid}
BIND( "Pyramid" as ?typeName )
}

optional
{
?thing a ?type.
VALUES ?type {yago:Skyscraper104233124}
BIND( "Skyscraper" as ?typeName )
}

optional
{
?thing a ?type.
VALUES ?type {dbo:Park}
BIND( "Park" as ?typeName )
}

optional
{
?thing a ?type.
VALUES ?type {yago:Church103028079}
BIND( "Church" as ?typeName )
}

optional
{
?thing geo:long ?long.
?thing geo:lat ?lat
}


{
?thing a dbo:Place
}

filter (BOUND (?type))

}