John, it's not my site, I'm just subscribed to the mailing list and  
sometimes respond to questions if I happen to know the answer.

The suggestion that someone else posted before -- to use bif:contains  
instead of regex -- works for me:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?label ?x
WHERE {
     ?x rdfs:label ?label.
     FILTER bif:contains(?label, "engine")
}

If you want only those labels that *end* in engine, then you can  
combine bif:contains and regex:

     FILTER (bif:contains(?label, "engine") AND regex(?label, "engine 
$", "i"))

Evaluation of regular expressions is expensive. I'm not too surprised  
that Virtuoso won't answer regex queries over 100s of millions of  
literals. bif:contains uses an information retrieval style full-text  
index which is much faster.

Best,
Richard


On 16 Dec 2009, at 17:52, John Abjanic wrote:

> Hi Richard,
>
> I tried what you suggested and it did not work.
>
> I get a:
> HttpException: HttpException: 500 SPARQL Request Failed: rethrew:
> HttpException: 500 SPARQL Request Failed
>
> I have tried  this type of query on 2 other web site
> endpoints and it works quite well.
>
> PREFIX  rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
> PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#
>
>     SELECT      ?label ?x
>     WHERE
>      {
>     ?x  rdfs:label ?label.
>       FILTER regex(?label, "(?i)engine").
>     }
>
> One of the sites bio2rdf.org uses virtuoso and
> Another one does not.
>
> The following query works ok at your site:
> PREFIX  rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
> PREFIX  rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
>
>      SELECT      ?label ?x
>      WHERE
>       {
>      ?x  rdfs:label ?label.
>      ?x  rdfs:label "Steam engine"@en
>      }
>
> But for my application I need to find and return all the
> engines such as:
>
> Jet engine
> Steam engine
> Rocket engine
> Search engine
> etc.
>
> I also need to do the same for other terms besides
> Just "engine" such as "aircraft"
>
> I believe there is something wrong with the way your
> Virtuoso server is setup.
> Why would this type of query work at other sites.
> Could you please raise this issue with the
> Virtuoso folks who manage your site.
>
>
> Thanks, John
>
> -----Original Message-----
> From: Richard Cyganiak [mailto:[email protected]]
> Sent: Wednesday, December 16, 2009 3:29 AM
> To: John Abjanic
> Cc: 'Mauricio Chicalski'; [email protected]
> Subject: Re: [Dbpedia-discussion] problem with SPARQL query
>
>
> On 16 Dec 2009, at 00:43, John Abjanic wrote:
>>    FILTER regex(?label, "(?i)engine"@en).
>
> I haven't seen this (?i) syntax before. I would have tried something
> like
>
> regex(?label, ".*engine", "i")
>
> .* matches any sequence of characters. The third parameter should make
> the match case insensitive. I don't think that the @en is going to
> work here, you'll have to use a separate FILTER with lang(?label)="en"
> or something like that.
>
> I haven't tried anything of the above, so my apologies if it's
> rubbish :-/
>
> Richard
>
>
>>
>> }
>>
>>
>> Thanks, John
>>
>>
>> -----Original Message-----
>> From: Mauricio Chicalski [mailto:[email protected]]
>> Sent: Tuesday, December 15, 2009 2:32 PM
>> To: John Abjanic
>> Cc: Richard Cyganiak; [email protected]
>> Subject: Re: [Dbpedia-discussion] problem with SPARQL query
>>
>> hi,
>> with jena i use
>> PREFIX fn:<http://www.w3.org/2005/xpath-functions#
>> <http://www.w3.org/2005/xpath-functions> >
>> ...
>> fn:contains(srt(?z), 'abc')
>>
>> I dont remember why virtuoso get error with fn, so u need to use
>> bif:contains(), no external ns needed
>>
>> ex:
>> PREFIX  property: <http://dbpedia.org/property/>
>>
>>    SELECT ?y ?z
>>    WHERE
>>     {
>>    <http://dbpedia.org/resource/Land_Rover>  ?y ?z .
>>    FILTER bif:contains(?z, 'made')
>>    }
>>
>> if u try this filter in a large resultset it will time out
>>
>> =]
>> On Tue, Dec 15, 2009 at 7:50 PM, John Abjanic <[email protected]>
>> wrote:
>> I also tried the following but it timed out, no response:
>>
>> PREFIX  rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
>> <http://www.w3.org/1999/02/22-rdf-syntax-ns> >
>> PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#
>> <http://www.w3.org/2000/01/rdf-schema> >
>>
>>    SELECT      ?label ?x
>>    WHERE
>>     {
>>    ?x  rdfs:label ?label.
>>    FILTER regex(?label, "(?i)engine"@en).
>>
>>
>> Please advise.
>>
>> -John
>>
>> -----Original Message-----
>> From: Richard Cyganiak [mailto:[email protected]]
>> Sent: Tuesday, December 15, 2009 12:43 PM
>> To: John Abjanic
>> Cc: [email protected]
>> Subject: Re: [Dbpedia-discussion] problem with SPARQL query
>> Hi John,
>>
>> Try "Jet engine"@en. The literal has an RDF language tag to indicate
>> that it's the English label.
>>
>> Best,
>> Richard
>>
>>
>>
>>
>> On 15 Dec 2009, at 19:47, John Abjanic wrote:
>>
>>> Hello all,
>>>
>>> I am trying to do the following:
>>>
>>> PREFIX  rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#
>> <http://www.w3.org/1999/02/22-rdf-syntax-ns> >
>>> PREFIX  rdfs: <http://www.w3.org/2000/01/rdf-schema#
>> <http://www.w3.org/2000/01/rdf-schema> >
>>>
>>>    SELECT      ?label ?x
>>>    WHERE
>>>     {
>>>    ?x  rdfs:label ?label.
>>>   ?x  rdfs:label  "Jet engine"
>>>
>>>    }
>>>
>>>
>>> and I get no results
>>> but when I try:
>>>
>>> SELECT ?s ?p ?o
>>> WHERE {
>>> ?s ?p ?o.
>>> FILTER(?s = <http://dbpedia.org/resource/Jet_engine> ).
>>> }
>>>
>>> I get results and there is  label for "Jet engine"
>>>
>>> http://dbpedia.org/resource/Jet_engine
>>> http://www.w3.org/2000/01/rdf-schema#label
>>> Jet engine
>>>
>>>
>>>
>>>
>>> Why does the 1st SPARQL not work right?
>>>
>>> Thanks, John
>>>
>>
> ------------------------------------------------------------------------
>> ------
>>> This SF.Net email is sponsored by the Verizon Developer Community
>>> Take advantage of Verizon's best-in-class app development support
>>> A streamlined, 14 day to market process makes app distribution fast
>>> and easy
>>> Join now and get one step closer to millions of Verizon customers
>>> http://p.sf.net/sfu/verizon-dev2dev
>>> _______________________________________________
>>> Dbpedia-discussion mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
>>
>>
>>
> ------------------------------------------------------------------------
>> ------
>> This SF.Net email is sponsored by the Verizon Developer Community
>> Take advantage of Verizon's best-in-class app development support
>> A streamlined, 14 day to market process makes app distribution fast
>> and
>> easy
>> Join now and get one step closer to millions of Verizon customers
>> http://p.sf.net/sfu/verizon-dev2dev
>> _______________________________________________
>> Dbpedia-discussion mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion
>>
>


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Dbpedia-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion

Reply via email to