Dear Mr., I thank you for the query. This is absolutely useful to ameliorate data mining methods for Wikidata. I always said that Wikidata Query Service is still misused. Yours Sincerely, Houcemeddine Turki (he/him) Medical Student, Faculty of Medicine of Sfax, University of Sfax, Tunisia GLAM, Research and Education Coordinator, Wikimedia TN User Group Member, Wiki Project Med Member, WikiIndaba Steering Committee Member, Wikimedia and Library User Group Steering Committee ____________________ +21629499418
-------- Message d'origine -------- De : Ettore RIZZA ettorerizza@gmail.com Date : 2019/10/04 09:15 (GMT+01:00) À : Discussion list for the Wikidata project wikidata@lists.wikimedia.org Objet : Re: [Wikidata] Full-text / autocomplete search on labels
Hello Thomas,
You can perform a full text search with the API, but not yet with SPARQL AFAIK. However, it is possible to call the API in a SPARQL query. For example, here is a queryhttps://query.wikidata.org/#SELECT%20DISTINCT%20%3Fperson%20%3FpersonLabel%20WHERE%20%7B%0A%20%20SERVICE%20wikibase%3Amwapi%20%7B%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aapi%20%22EntitySearch%22%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aendpoint%20%22www.wikidata.org%22%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20mwapi%3Asearch%20%22einst%22%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20mwapi%3Alanguage%20%22en%22%20.%0A%20%20%20%20%20%20%3Fperson%20wikibase%3AapiOutputItem%20mwapi%3Aitem%20.%0A%20%20%7D%0A%20%20%3Fperson%20wdt%3AP31%20wd%3AQ5.%0A%20%20%0A%20%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%20%20%0A%20%20%0A%7D%20ORDER%20BY%20DESC(%3Fperson)%20LIMIT%2020 that looks for "human (Q5)" whose label contains the string "einst".
Hope this helps,
Ettore Rizza
On Fri, 4 Oct 2019 at 09:58, Thomas Francart <thomas.francart@sparna.frmailto:thomas.francart@sparna.fr> wrote: Hello
I understand the wikidata SPARQL label service only fetches the labels, but does not allow to search/filter on them; labels are also available in regulare rdfs:label on which a FILTER can be made. However I would like to do full-text search over labels, to e.g. feed an autocomplete search field, actually just like the usual top-right wikidata search field does. I would also be interested to combine this with a criteria on "instance of", to search only on instances of a given class.
Can I do that efficiently using the Wikidata SPARQL service ? or is there a separate API I could use ? (exemple welcome)
Thanks Thomas
--
Thomas Francart - SPARNA Web de données | Architecture de l'information | Accès aux connaissances blog : blog.sparna.frhttp://blog.sparna.fr, site : sparna.frhttp://sparna.fr, linkedin : fr.linkedin.com/in/thomasfrancarthttps://fr.linkedin.com/in/thomasfrancart tel : +33 (0)6.71.11.25.97, skype : francartthomas _______________________________________________ Wikidata mailing list Wikidata@lists.wikimedia.orgmailto:Wikidata@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata
A few things of note: 1. the label service adds its variables very late during query evaluation; at the point where you try to FILTER on ?humanLabel, the label service hasn’t created that variable yet. 2. 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: 3. One can also use FILTER with a regular expression. In the following example
SELECT ?item ?itemLabel ?bblidWHERE { ?item wdt:P2580 ?bblid . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } FILTER(!REGEX(STR(?bblid), "[\.q]")) }
Read thoroughly the FILTER section in the Wikidata:SPARQL tutorial https://www.wikidata.org/wiki/Wikidata:SPARQL_tutorial#FILTER to read more about options above and others FILTER functions available.
Here's some extra example's:
https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples...
https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples...
https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples...
https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples...
Thad https://www.linkedin.com/in/thadguidry/
On Fri, Oct 4, 2019 at 6:09 AM Houcemeddine A. Turki < turkiabdelwaheb@hotmail.fr> wrote:
Dear Mr., I thank you for the query. This is absolutely useful to ameliorate data mining methods for Wikidata. I always said that Wikidata Query Service is still misused. Yours Sincerely, Houcemeddine Turki (he/him) Medical Student, Faculty of Medicine of Sfax, University of Sfax, Tunisia GLAM, Research and Education Coordinator, Wikimedia TN User Group Member, Wiki Project Med Member, WikiIndaba Steering Committee Member, Wikimedia and Library User Group Steering Committee ____________________ +21629499418
-------- Message d'origine -------- De : Ettore RIZZA ettorerizza@gmail.com Date : 2019/10/04 09:15 (GMT+01:00) À : Discussion list for the Wikidata project wikidata@lists.wikimedia.org
Objet : Re: [Wikidata] Full-text / autocomplete search on labels
Hello Thomas,
You can perform a full text search with the API, but not yet with SPARQL AFAIK. However, it is possible to call the API in a SPARQL query. For example, here is a query https://query.wikidata.org/#SELECT%20DISTINCT%20%3Fperson%20%3FpersonLabel%20WHERE%20%7B%0A%20%20SERVICE%20wikibase%3Amwapi%20%7B%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aapi%20%22EntitySearch%22%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20wikibase%3Aendpoint%20%22www.wikidata.org%22%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20mwapi%3Asearch%20%22einst%22%20.%0A%20%20%20%20%20%20bd%3AserviceParam%20mwapi%3Alanguage%20%22en%22%20.%0A%20%20%20%20%20%20%3Fperson%20wikibase%3AapiOutputItem%20mwapi%3Aitem%20.%0A%20%20%7D%0A%20%20%3Fperson%20wdt%3AP31%20wd%3AQ5.%0A%20%20%0A%20%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22%5BAUTO_LANGUAGE%5D%2Cen%22.%20%7D%0A%20%20%0A%20%20%0A%7D%20ORDER%20BY%20DESC(%3Fperson)%20LIMIT%2020 that looks for "human (Q5)" whose label contains the string "einst".
Hope this helps,
Ettore Rizza
On Fri, 4 Oct 2019 at 09:58, Thomas Francart thomas.francart@sparna.fr wrote:
Hello
I understand the wikidata SPARQL label service only fetches the labels, but does not allow to search/filter on them; labels are also available in regulare rdfs:label on which a FILTER can be made. However I would like to do full-text search over labels, to e.g. feed an autocomplete search field, actually just like the usual top-right wikidata search field does. I would also be interested to combine this with a criteria on "instance of", to search only on instances of a given class.
Can I do that efficiently using the Wikidata SPARQL service ? or is there a separate API I could use ? (exemple welcome)
Thanks Thomas
--
*Thomas Francart* -* SPARNA* Web de *données* | Architecture de l'*information* | Accès aux *connaissances* blog : blog.sparna.fr, site : sparna.fr, linkedin : fr.linkedin.com/in/thomasfrancart tel : +33 (0)6.71.11.25.97, skype : francartthomas _______________________________________________ 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