2

python用来运行一些sparql查询。我想从中提取信息 http://factforge.net/sparql

sparql = SPARQLWrapper("http://factforge.net/sparql")
query = """
# F02: Big Cities in Eastern Europe

PREFIX onto: <http://www.ontotext.com/>
PREFIX gn: <http://www.geonames.org/ontology#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT * FROM onto:disable-sameAs
WHERE {
    SERVICE <http://factforge.net/sparql>{
    ?loc gn:parentFeature dbr:Eastern_Europe ; 
         gn:featureClass  gn:P;
         gn:featureCode gn:A.ADM2.
    ?loc dbo:populationTotal ?population ; dbo:country ?country .
    ?country a dbo:Country .
    }
    FILTER(?population > 300000 )
    ?country skos:prefLabel ?country_name . 

} ORDER BY ?country_name DESC(?population)

"""
sparql.setQuery(query)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()

此查询适用于factforge网站,但在本地我收到以下错误EndPointNotFound: it was impossible to connect with the endpoint in that address, check if it is correct.

4

1 回答 1

3

GraphDB 公开了 RDF4J 风格的 API。这正是帮助页面上所说的。

SPARQL 端点地址应该是http://factforge.net/repositories/{repositoryID}.

不幸的是,无法从 GraphDB 中的 SPARQL 确定使用哪个存储库。

为此,您可以在浏览器中使用 F12 开发人员工具。或者关于页面说:

应用程序可以通过http://factforge.net/repositories/ff-news上的 SPARQL 访问 FactForge 。
这也是用于联合 SPARQL 查询的服务地址。

于 2017-11-23T18:05:11.480 回答