2

i'm building an integration system that makes a query to the prefixSearch Api of dbPedia

http://lookup.dbpedia.org/api/search.asmx/PrefixSearch?QueryClass=&MaxHits=1&QueryString=KEYWORD

From this i obtain an URI of a resource and get the resource using a simple get and i parse it using nokogiri

data = Net::HTTP.get(URI.parse(url.to_s+'.rdf'))
doc = Nokogiri::XML(data)

from the doc i need to find the abstract , so using xpath i find it successfully .

entity = doc.root.xpath("/rdf:RDF/rdf:Description[@rdf:about=\""+@uri+"\"]").map do |node|  
name = node.xpath("dbpedia-owl:abstract[@xml:lang=\"en\"]").first.content
end

The problem is that for some pages that are information rich, like the pages referring to nations, doing this operation will takes 15-16 seconds. this is not acceptable in my system.

So i need to find a way to do all the things faster? Is there any solution? For instance using SPARQL Thanks to all

Himanshu
  • 2,400
  • 1
  • 20
  • 37
dbonadiman
  • 267
  • 2
  • 7

1 Answers1

3

If you only need specific information about the URI then likely you can write a SPARQL query for just that information which should make things much faster.

You need to elaborate on exactly what information you need but I assume you are looking for the english abstract about the URI based on the code you showed:

PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>

SELECT ?abstract
WHERE
{
  <http://dbpedia.org/resource/RESOURCE> dbpedia-owl:abstract ?abstract .
  FILTER(LANGMATCHES(LANG(?abstract), "en"))
}
RobV
  • 26,016
  • 10
  • 71
  • 114
  • It is useful i don't used before because scared about a new query language but thanks to your answer i understand how it work.Now the loading time of my page is 0.2 sec – dbonadiman Jan 08 '13 at 12:57