You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by 朱曼 <zh...@gmail.com> on 2011/08/08 16:14:47 UTC
is count function supported?
Dear list,
The following code causes "com.hp.hpl.jena.query.QueryParseException". Is
count function supported?
import com.hp.hpl.jena.query.*;
String queDBPedia = "select count(?inst)\n"
+ "from <http://dbpedia.org>\n"
+ "where {?inst a <
http://dbpedia.org/ontology/Activity>}";
Query query = QueryFactory.create(queDBPedia);
Or do I need to count the total number after I get all the instances?
Thanks for your time!
Best regards
June
Re: is count function supported?
Posted by Andy Seaborne <an...@epimorphics.com>.
Or parse as syntaxARQ for extensions.
Generally, the system behaves in standards mode unless you tell it
otherwise. It's a choice - more questions, better understanding of
what's standard. Some other systems the other choice - extensions on by
default (if turn-off-able at all).
Andy
On 08/08/11 15:25, 朱曼 wrote:
> Dear Rob and Damian,
>
> Thanks very much! it works~
>
> Best regards,
>
> June
>
>
> 2011/8/8 Damian Steer<d....@bristol.ac.uk>
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> On 08/08/11 15:14, ?? wrote:
>>> Dear list,
>>>
>>> The following code causes "com.hp.hpl.jena.query.QueryParseException". Is
>>> count function supported?
>>>
>>> import com.hp.hpl.jena.query.*;
>>> String queDBPedia = "select count(?inst)\n"
>>
>> SPARQL 1.1 syntax requires an assignment, so try:
>>
>> select (count(?inst) as ?instcount) ...
>>
>> Damian
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.11 (GNU/Linux)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>>
>> iEYEARECAAYFAk4/8VoACgkQAyLCB+mTtyls6QCg9kivkVd6U0M5cCOprVhHKS9r
>> C94An2fR/QlcrAK7BwGWvXjAEPycnzsu
>> =tzct
>> -----END PGP SIGNATURE-----
>>
>
Re: is count function supported?
Posted by 朱曼 <zh...@gmail.com>.
Dear Rob and Damian,
Thanks very much! it works~
Best regards,
June
2011/8/8 Damian Steer <d....@bristol.ac.uk>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 08/08/11 15:14, ?? wrote:
> > Dear list,
> >
> > The following code causes "com.hp.hpl.jena.query.QueryParseException". Is
> > count function supported?
> >
> > import com.hp.hpl.jena.query.*;
> > String queDBPedia = "select count(?inst)\n"
>
> SPARQL 1.1 syntax requires an assignment, so try:
>
> select (count(?inst) as ?instcount) ...
>
> Damian
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk4/8VoACgkQAyLCB+mTtyls6QCg9kivkVd6U0M5cCOprVhHKS9r
> C94An2fR/QlcrAK7BwGWvXjAEPycnzsu
> =tzct
> -----END PGP SIGNATURE-----
>
Re: is count function supported?
Posted by Damian Steer <d....@bristol.ac.uk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/08/11 15:14, ?? wrote:
> Dear list,
>
> The following code causes "com.hp.hpl.jena.query.QueryParseException". Is
> count function supported?
>
> import com.hp.hpl.jena.query.*;
> String queDBPedia = "select count(?inst)\n"
SPARQL 1.1 syntax requires an assignment, so try:
select (count(?inst) as ?instcount) ...
Damian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk4/8VoACgkQAyLCB+mTtyls6QCg9kivkVd6U0M5cCOprVhHKS9r
C94An2fR/QlcrAK7BwGWvXjAEPycnzsu
=tzct
-----END PGP SIGNATURE-----
Re: is count function supported?
Posted by Paolo Castagna <ca...@googlemail.com>.
As Rob and Damian have already noted:
"It should be noted that as per functions, aggregate expressions are
required to be aliased (again, similar to the BIND clause, using the
keyword 'AS') in order to project them from queries or subqueries."
-- http://www.w3.org/TR/sparql11-query/#aggregateExample
Paolo
PS:
I bet we will see this question again, and again, and again... ;-)
朱曼 wrote:
> Dear list,
>
> The following code causes "com.hp.hpl.jena.query.QueryParseException". Is
> count function supported?
>
> import com.hp.hpl.jena.query.*;
> String queDBPedia = "select count(?inst)\n"
> + "from <http://dbpedia.org>\n"
> + "where {?inst a <
> http://dbpedia.org/ontology/Activity>}";
> Query query = QueryFactory.create(queDBPedia);
>
> Or do I need to count the total number after I get all the instances?
> Thanks for your time!
>
> Best regards
>
> June
>
RE: is count function supported?
Posted by Rob Vesse <ra...@ecs.soton.ac.uk>.
Aggregates and Project Expressions in SPARQL 1.1 require that you use
brackets around them and that they be aliased using the AS keyword e.g.
SELECT (COUNT(?inst) AS ?instances) FROM <http://dbpedia.org> WHERE { ?inst
a <http://dbpedia.org/ontology/Activity> }
If you change your query to the above it should work fine unless you are
using a really outdated version of ARQ.
Regards,
Rob
> -----Original Message-----
> From: 朱曼 [mailto:zhuman.private@gmail.com]
> Sent: 08 August 2011 15:15
> To: jena-users@incubator.apache.org
> Subject: is count function supported?
>
> Dear list,
>
> The following code causes "com.hp.hpl.jena.query.QueryParseException".
> Is
> count function supported?
>
> import com.hp.hpl.jena.query.*;
> String queDBPedia = "select count(?inst)\n"
> + "from <http://dbpedia.org>\n"
> + "where {?inst a <
> http://dbpedia.org/ontology/Activity>}";
> Query query = QueryFactory.create(queDBPedia);
>
> Or do I need to count the total number after I get all the instances?
> Thanks for your time!
>
> Best regards
>
> June