1

I am working on a project and I want to make use of DBpedia. I have few hundreds of DBpedia links like

What is better use of time:

  • to crawl those pages and extract the information that I want?
  • to query the data with a SPARQL query from Python?
4

1 回答 1

6

首先,注意标识 DBpedia 资源的 URI 不是

页面,但是

资源。其次,使用 SPARQL 检索信息会更快。SPARQL 是一种用于 RDF 的查询语言,您正在寻找 RDF 数据。在 SPARQL 中获取有关 FEMA 的信息所需要做的就是一个 describe 查询:

describe
  dbpedia:Federal_Emergency_Management_Agency

SPARQL 结果

描述查询可以描述多个资源,因此您可以这样做,例如:

describe
  dbpedia:Federal_Emergency_Management_Agency
  dbpedia:Mount_Monadnock
  # more resources...

SPARQL 结果

如果您只需要有关某些资源的某些信息,您仍然可以使用选择或构造查询执行类似的操作,使用values并以编程方式注入您感兴趣的资源:

select ?label where { 
  values ?resource {
    dbpedia:Federal_Emergency_Management_Agency # put your values in here and
    dbpedia:Mount_Monadnock                     # ?resource will be bound to each
  }
  ?resource rdfs:label ?label .
  filter( langMatches( lang(?label), "EN" ))
}

SPARQL 结果

您还可以使用构造在模型中获取这些三元组:

construct {
  ?resource rdfs:label ?label 
}
where { 
  values ?resource {
    dbpedia:Federal_Emergency_Management_Agency
    dbpedia:Mount_Monadnock
  }
  ?resource rdfs:label ?label .
  filter( langMatches( lang(?label), "EN" ))
}

SPARQL 结果

于 2013-09-18T16:30:34.947 回答