On Sat, Dec 7, 2013 at 6:52 PM, Timothy Lebo <le...@rpi.edu> wrote:
> The following query for the number of universities in each country is a bit 
> “ugly”. For example,
>
> 1) Countries are identified with URIs or Strings, and the same country is 
> identified in many different ways.
> 2) The country “20” has three universities :-)
>
> I’m not very familiar with the workflow that DBPedia has, but I’m curious 
> what I could do to fix the results as “upstream” as possible.
> Is there a “how to help” page somewhere that I could read?
> Or, could someone provide me a few pointers to get started?
>
> Thanks for your consideration.
>
> Regards,
> Tim Lebo
>
>
> http://dbpedia.org/sparql
>
> {{{
> prefix dbpedia: <http://dbpedia.org/resource/>
> prefix dbo:     <http://dbpedia.org/ontology/>
> prefix dbp:     <http://dbpedia.org/property/>
>
> select ?country count(distinct ?university) as ?count
> where {
>            ?university dbo:type dbpedia:Public_university
>   optional{?university dbp:country ?country}
> }
> group by ?country
> order by desc(?count)
> }}}

In your query, you're using the raw infobox data.  That data is much
more noisy than the data in the DBpedia Ontology.  If you restrict
yourself to the DBpedia ontology, you'll get much more sensible
results.  E.g., if you execute this query on the DBpedia SPARQL
endpoint (http://dbpedia.org/sparql) (which includes the prefix
dbpedia-owl: <http://dbpedia.org/ontology/>):

  select ?country (count(?university) as ?count)
  where {
    ?university a dbpedia-owl:University
    optional{ ?university dbpedia-owl:country ?country}
  }
  group by ?country

you get much better results.  For more about the differences, see this
StackOverflow question (http://stackoverflow.com/q/17237144/1281433),
and some of the DBpedia documentation that the answer links to.  Happy
SPARQLing!

//JT
-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Dbpedia-discussion mailing list
Dbpedia-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion

Reply via email to