Issues again!
This is the current version of my query. (A reminder: I'm trying to grab a
list of all the articles that are a member of Category:Pasta, ordered first
by number of inlinks each of those articles has and then by label):
SELECT
?uri, ?label, count(*) as ?inlinks
FROM
<http://dbpedia.org/pagelinks#>
WHERE {
?uri skos:subject <http://dbpedia.org/resource/Category:Pasta> .
OPTIONAL {?uri rdfs:label ?label} .
OPTIONAL {?inlink dbpedia2:wikilink ?uri} .
FILTER (langMatches(lang(?label), "en"))
}
ORDER BY DESC(?inlinks) ASC(?label)
This query gives me the correct results. I have an OPTIONAL around the
?label retrieval out of trial and error. This query (same thing without the
optional):
SELECT
?uri, ?label, count(*) as ?inlinks
FROM
<http://dbpedia.org/pagelinks#>
WHERE {
?uri skos:subject <http://dbpedia.org/resource/Category:Pasta> .
?uri rdfs:label ?label .
OPTIONAL {?inlink dbpedia2:wikilink ?uri} .
FILTER (langMatches(lang(?label), "en"))
}
ORDER BY DESC(?inlinks) ASC(?label)
Yields some weird results. Scroll down to :Al_forno or :Al_dente. Why are
their labels "Campanelle" and "Fiori (pasta)"? :Passatelli and
:O.B._Macaroni also have mismatched labels. Their connection? They are the
only articles in the results that don't have any inlinks (ideally their
inlink count would be 0 but I don't know how to form a query to do
that...). If I take ?label out of the ORDER BY the mismatching is
fixed...but I don't have my desired ordering:
SELECT
?uri, ?label, count(*) as ?inlinks
FROM
<http://dbpedia.org/pagelinks#>
WHERE {
?uri skos:subject <http://dbpedia.org/resource/Category:Pasta> .
?uri rdfs:label ?label .
OPTIONAL {?inlink dbpedia2:wikilink ?uri} .
FILTER (langMatches(lang(?label), "en"))
}
ORDER BY DESC(?inlinks)
Is this another bug? Or am I botching the SPARQL...or both again?
I appreciate the help,
Matt
--
Matt Mullins
Computer Science Department, Western Washington University
On Fri, Aug 7, 2009 at 7:54 AM, Kingsley Idehen <[email protected]>wrote:
> Matt Mullins wrote:
>
>> Ivan,
>>
>> That works wonderfully, thank you! I could've sworn I tried count(*)
>> (which works, too) but I was probably changing too many variables at
>> once trying to troubleshoot this. Your second query definitely was
>> one of the ones I tried and makes the most sense to me.
>>
>>
>> Thanks again,
>>
>> Matt
>>
>> --
>> Matt Mullins
>> Computer Science Department, Western Washington University
>>
>> On Thu, Aug 6, 2009 at 9:06 PM, Ivan Mikhailov
>> <[email protected] <mailto:[email protected]>> wrote:
>>
>> Hello Matt,
>>
>> Aggregating by grouped expression is formally senseless and should
>> signal an error, The problem is that the error is not signaled, the
>> error diagnostics should be improved.
>>
>> The compiler go crazy and result
>> from one grouping is used for all groups.
>>
>> This works:
>>
>> SELECT
>> ?label ?uri count(1) as ?count
>> FROM
>> <http://dbpedia.org/pagelinks#>
>> WHERE {
>> ?uri skos:subject <http://dbpedia.org/resource/Category:Pasta> .
>> ?uri rdfs:label ?label .
>> ?link dbpedia2:wikilink ?uri .
>> FILTER (langMatches(lang(?label), "en"))
>> }
>> GROUP BY ?label ?uri
>> ORDER BY ?count
>>
>>
>> Best Regards,
>> Ivan.
>>
>> P.S. The real bug is that correct query
>>
>> SELECT
>> ?label ?uri count(?link) as ?count
>> FROM
>> <http://dbpedia.org/pagelinks#>
>> WHERE {
>> ?uri skos:subject <http://dbpedia.org/resource/Category:Pasta> .
>> ?uri rdfs:label ?label .
>> ?link dbpedia2:wikilink ?uri .
>> FILTER (langMatches(lang(?label), "en"))
>> }
>> GROUP BY ?label ?uri
>> ORDER BY ?count
>>
>> does not work :|
>>
>> Correct, and it needs to be fixed.
>
> Kingsley
>
>>
>>
>>
>>
>> On Thu, 2009-08-06 at 15:40 -0400, Kingsley Idehen wrote:
>> > Matt Mullins wrote:
>> > > Hello,
>> > >
>> > > I'm having a little trouble forming a query that will tally
>> how many
>> > > pagelinks there are per page. The following query works to
>> grab the
>> > > links themselves:
>> > >
>> > > SELECT
>> > > ?label ?uri ?link
>> > > FROM
>> > > <http://dbpedia.org/pagelinks#>
>> > > WHERE {
>> > > ?uri skos:subject
>> <http://dbpedia.org/resource/Category:Pasta> .
>> > > ?uri rdfs:label ?label .
>> > > ?link dbpedia2:wikilink ?uri .
>> > > FILTER (langMatches(lang(?label), "en"))
>> > > }
>> > >
>> > > And this one works to grab what seem to be accurate counts:
>> > >
>> > > SELECT
>> > > ?label ?uri count(?uri) as ?count
>> > > FROM
>> > > <http://dbpedia.org/pagelinks#>
>> > > WHERE {
>> > > ?uri skos:subject
>> <http://dbpedia.org/resource/Category:Pasta> .
>> > > ?uri rdfs:label ?label .
>> > > ?link dbpedia2:wikilink ?uri .
>> > > FILTER (langMatches(lang(?label), "en"))
>> > > }
>> > > GROUP BY ?label ?uri
>> > >
>> > > But when I try to order these results by count, all counts are the
>> > > same (6 in this case):
>> > >
>> > > SELECT
>> > > ?label ?uri count(?uri) as ?count
>> > > FROM
>> > > <http://dbpedia.org/pagelinks#>
>> > > WHERE {
>> > > ?uri skos:subject
>> <http://dbpedia.org/resource/Category:Pasta> .
>> > > ?uri rdfs:label ?label .
>> > > ?link dbpedia2:wikilink ?uri .
>> > > FILTER (langMatches(lang(?label), "en"))
>> > > }
>> > > GROUP BY ?label ?uri
>> > > ORDER BY ?count
>> > >
>> > > Any ideas? It's still a little boggling to me how aggregates are
>> > > supposed to work... I'm probably just butchering the
>> documentation
>> > > [1] and interpreting it incorrectly.
>> > >
>> > >
>> > > Matt
>> > >
>> > > [1] http://docs.openlinksw.com/virtuoso/rdfsparqlaggregate.html
>> >
>> > Matt,
>> >
>> > Its a darn bug :-(
>> >
>> >
>> > Kingsley
>> >
>> > >
>> > >
>> > > --
>> > > Matt Mullins
>> > > Computer Science Department, Western Washington University
>> > >
>>
>> ------------------------------------------------------------------------
>> > >
>> > >
>>
>>
>> ------------------------------------------------------------------------------
>> > > Let Crystal Reports handle the reporting - Free Crystal
>> Reports 2008 30-Day
>> > > trial. Simplify your report design, integration and deployment
>> - and focus on
>> > > what you do best, core application coding. Discover what's new
>> with
>> > > Crystal Reports now. http://p.sf.net/sfu/bobj-july
>> > >
>>
>> ------------------------------------------------------------------------
>> > >
>> > > _______________________________________________
>> > > Dbpedia-discussion mailing list
>> > > [email protected]
>> <mailto:[email protected]>
>> > > https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
>> > >
>> >
>> >
>>
>>
>>
>
> --
>
>
> Regards,
>
> Kingsley Idehen Weblog:
> http://www.openlinksw.com/blog/~kidehen<http://www.openlinksw.com/blog/%7Ekidehen>
> President & CEO
> OpenLink Software Web: http://www.openlinksw.com
>
>
>
>
>
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Dbpedia-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion