Re: [Wikidata] Where did label filtering break recently and how?

2019-06-01 Thread Lucas Werkmeister
For this query, you can also use the regular Wikibase search, either
skipping the query service completely –

https://www.wikidata.org/wiki/Special:Search/haswbstatement:P31=Q2085381
inlabel:simon@en

https://www.wikidata.org/w/api.php?action=query=search=haswbstatement:P31=Q2085381%20inlabel:simon@en

– or combining the query service with the search API via MWAPI
:

SELECT ?publisher ?publisherLabel WHERE {
  SERVICE wikibase:mwapi {
    bd:serviceParam wikibase:api "Search";
    wikibase:endpoint "www.wikidata.org";
    mwapi:srsearch "haswbstatement:P31=Q2085381
inlabel:simon@[AUTO_LANGUAGE]".
    ?publisher wikibase:apiOutputItem mwapi:title.
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language
"[AUTO_LANGUAGE],en". }
}

Try it!


On 01.06.19 11:51, Thad Guidry wrote:
> Found my answer !!!  had to go back to the SPARQL Tutorial page and
> re-read the section on FILTER
> ...specifically...
>  
>
> The label service is very useful if you just want to display the
> label of a variable. *But if you want to do stuff with the
> label** *... 
>
>  
> yes, I do want to have an expression about a label..., in fact, 95% of
> the time that's what I want to do...so why doesn't the darn label
> service help me do that better?
>
> The reason why this doesn’t work is that the label service adds
> its variables very late during query evaluation; at the point
> where we try to filter on |?humanLabel|, the label service hasn’t
> created that variable yet.
> Fortunately, the label service isn’t the only way to get an item’s
> label. Labels are also stored as regular triples, using the
> predicate |rdfs:label|. Of course, this means all labels, not just
> English ones; if we only want English labels, we’ll have to filter
> on the language of the label:
>
>
> AH !  label service does things AFTER the query returns results.
>
> So this works, and is how you actually handle label filtering
> *without* using the label service, and instead getting the label
> stored as a triple (and it's twice as fast as well)...
>
> SELECT ?publisher ?label
> WHERE
> {
>   ?publisher wdt:P31 wd:Q2085381;
>          rdfs:label ?label.
>   FILTER(LANG(?label) = "[AUTO_LANGUAGE]").
>   FILTER CONTAINS(LCASE(?label), "simon").
> }
>
> Thad
> https://www.linkedin.com/in/thadguidry/
>
>
> ___
> Wikidata mailing list
> Wikidata@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikidata
___
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata


Re: [Wikidata] Where did label filtering break recently and how?

2019-06-01 Thread Thad Guidry
Found my answer !!!  had to go back to the SPARQL Tutorial page and re-read the
section on FILTER

...specifically...

The label service is very useful if you just want to display the label of a
> variable. *But if you want to do stuff with the label* ...


yes, I do want to have an expression about a label..., in fact, 95% of the
time that's what I want to do...so why doesn't the darn label service help
me do that better?

The reason why this doesn’t work is that the label service adds its
> variables very late during query evaluation; at the point where we try to
> filter on ?humanLabel, the label service hasn’t created that variable yet.
> Fortunately, the label service isn’t the only way to get an item’s label.
> Labels are also stored as regular triples, using the predicate rdfs:label.
> Of course, this means all labels, not just English ones; if we only want
> English labels, we’ll have to filter on the language of the label:


AH !  label service does things AFTER the query returns results.

So this works, and is how you actually handle label filtering *without*
using the label service, and instead getting the label stored as a triple
(and it's twice as fast as well)...

SELECT ?publisher ?label
WHERE
{
  ?publisher wdt:P31 wd:Q2085381;
 rdfs:label ?label.
  FILTER(LANG(?label) = "[AUTO_LANGUAGE]").
  FILTER CONTAINS(LCASE(?label), "simon").
}

Thad
https://www.linkedin.com/in/thadguidry/
___
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata


Re: [Wikidata] Where did label filtering break recently and how?

2019-06-01 Thread Thad Guidry
Thanks Andra.
Is there no way to proactively without using a 2nd outer query to constrain
the query within the WHERE clause?  To help with faster query response?
In other words, hitting some index so that only publishers containing
"simon" are returned.

I'm having to relearn some of this after being away from WDQS for some time.

Thad
https://www.linkedin.com/in/thadguidry/


On Fri, May 31, 2019 at 3:56 AM Andra Waagmeester  wrote:

> Yes that is indeed my experience as well.
> You can process the results but then in a SELECT within a SELECT query.
>
> This works:
> SELECT * WHERE {
>   {SELECT ?item ?itemLabel  WHERE {
>?item wdt:P31 wd:Q2085381.
>
>   SERVICE wikibase:label { bd:serviceParam wikibase:language
> "[AUTO_LANGUAGE],en". }
>
> }}
>FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
> }
>
> Note the omission of the second FILTER. I suspect that the results of the
> service return labels without language tags.
>
> On Fri, May 31, 2019 at 8:12 AM Nicolas VIGNERON <
> vigneron.nico...@gmail.com> wrote:
>
>> Hi Thad,
>>
>> Did it ever works?
>> It was my understanding that if you want to manipulate the label (or the
>> description, or the alias), you need to explicitly call it and that the
>> SERVICE was for display only. At least, this is with this assumption that I
>> always wrote my query (or explained during SPARQL workshops) :/
>> Anyway, this query works :
>>
>> SELECT ?item ?itemLabel  WHERE {
>>?item wdt:P31 wd:Q2085381 ; rdfs:label ?itemLabel .
>>   FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
>>   FILTER (LANG(?itemLabel)="en")
>> }
>>
>> Cheers,
>> ~nicolas
>>
>> Le ven. 31 mai 2019 à 03:05, Thad Guidry  a écrit :
>>
>>> My Query:
>>>
>>> SELECT ?item ?itemLabel  WHERE {
>>>?item wdt:P31 wd:Q2085381.
>>>
>>>   SERVICE wikibase:label { bd:serviceParam wikibase:language
>>> "[AUTO_LANGUAGE],en". }
>>>   #   FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
>>>   #   FILTER (LANG(?itemLabel)="en")
>>> }
>>>
>>> and if I enable any of the FILTER lines, it returns 0 results.
>>> What changed / Why ?
>>>
>>> Thad
>>> https://www.linkedin.com/in/thadguidry/
>>> ___
>>> Wikidata mailing list
>>> Wikidata@lists.wikimedia.org
>>> https://lists.wikimedia.org/mailman/listinfo/wikidata
>>>
>> ___
>> Wikidata mailing list
>> Wikidata@lists.wikimedia.org
>> https://lists.wikimedia.org/mailman/listinfo/wikidata
>>
> ___
> Wikidata mailing list
> Wikidata@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikidata
>
___
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata


Re: [Wikidata] Where did label filtering break recently and how?

2019-05-31 Thread Andra Waagmeester
Yes that is indeed my experience as well.
You can process the results but then in a SELECT within a SELECT query.

This works:
SELECT * WHERE {
  {SELECT ?item ?itemLabel  WHERE {
   ?item wdt:P31 wd:Q2085381.

  SERVICE wikibase:label { bd:serviceParam wikibase:language
"[AUTO_LANGUAGE],en". }

}}
   FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
}

Note the omission of the second FILTER. I suspect that the results of the
service return labels without language tags.

On Fri, May 31, 2019 at 8:12 AM Nicolas VIGNERON 
wrote:

> Hi Thad,
>
> Did it ever works?
> It was my understanding that if you want to manipulate the label (or the
> description, or the alias), you need to explicitly call it and that the
> SERVICE was for display only. At least, this is with this assumption that I
> always wrote my query (or explained during SPARQL workshops) :/
> Anyway, this query works :
>
> SELECT ?item ?itemLabel  WHERE {
>?item wdt:P31 wd:Q2085381 ; rdfs:label ?itemLabel .
>   FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
>   FILTER (LANG(?itemLabel)="en")
> }
>
> Cheers,
> ~nicolas
>
> Le ven. 31 mai 2019 à 03:05, Thad Guidry  a écrit :
>
>> My Query:
>>
>> SELECT ?item ?itemLabel  WHERE {
>>?item wdt:P31 wd:Q2085381.
>>
>>   SERVICE wikibase:label { bd:serviceParam wikibase:language
>> "[AUTO_LANGUAGE],en". }
>>   #   FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
>>   #   FILTER (LANG(?itemLabel)="en")
>> }
>>
>> and if I enable any of the FILTER lines, it returns 0 results.
>> What changed / Why ?
>>
>> Thad
>> https://www.linkedin.com/in/thadguidry/
>> ___
>> Wikidata mailing list
>> Wikidata@lists.wikimedia.org
>> https://lists.wikimedia.org/mailman/listinfo/wikidata
>>
> ___
> Wikidata mailing list
> Wikidata@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikidata
>
___
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata


Re: [Wikidata] Where did label filtering break recently and how?

2019-05-31 Thread Nicolas VIGNERON
Hi Thad,

Did it ever works?
It was my understanding that if you want to manipulate the label (or the
description, or the alias), you need to explicitly call it and that the
SERVICE was for display only. At least, this is with this assumption that I
always wrote my query (or explained during SPARQL workshops) :/
Anyway, this query works :

SELECT ?item ?itemLabel  WHERE {
   ?item wdt:P31 wd:Q2085381 ; rdfs:label ?itemLabel .
  FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
  FILTER (LANG(?itemLabel)="en")
}

Cheers,
~nicolas

Le ven. 31 mai 2019 à 03:05, Thad Guidry  a écrit :

> My Query:
>
> SELECT ?item ?itemLabel  WHERE {
>?item wdt:P31 wd:Q2085381.
>
>   SERVICE wikibase:label { bd:serviceParam wikibase:language
> "[AUTO_LANGUAGE],en". }
>   #   FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
>   #   FILTER (LANG(?itemLabel)="en")
> }
>
> and if I enable any of the FILTER lines, it returns 0 results.
> What changed / Why ?
>
> Thad
> https://www.linkedin.com/in/thadguidry/
> ___
> Wikidata mailing list
> Wikidata@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikidata
>
___
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata


Re: [Wikidata] Where did label filtering break recently and how?

2019-05-30 Thread Stas Malyshev
Hi!

> and if I enable any of the FILTER lines, it returns 0 results.
> What changed / Why ?

Thanks for reporting, I'll check into it.

-- 
Stas Malyshev
smalys...@wikimedia.org

___
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata


Re: [Wikidata] Where did label filtering break recently and how?

2019-05-30 Thread Fariz Darari
Hello,

I also got a similar problem, the following does not return the label:

SELECT ?res ?resLabel WHERE {
SELECT ?res ?resLabel
WHERE {
   ?res wdt:P31 wd:Q5 .
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} LIMIT 1
}

Regards,
Fariz

On Fri, May 31, 2019 at 8:05 AM Thad Guidry  wrote:

> My Query:
>
> SELECT ?item ?itemLabel  WHERE {
>?item wdt:P31 wd:Q2085381.
>
>   SERVICE wikibase:label { bd:serviceParam wikibase:language
> "[AUTO_LANGUAGE],en". }
>   #   FILTER(CONTAINS(LCASE(?itemLabel), "simon"))
>   #   FILTER (LANG(?itemLabel)="en")
> }
>
> and if I enable any of the FILTER lines, it returns 0 results.
> What changed / Why ?
>
> Thad
> https://www.linkedin.com/in/thadguidry/
> ___
> Wikidata mailing list
> Wikidata@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikidata
>
___
Wikidata mailing list
Wikidata@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata