Hi there,
I have just discovered the Linked Data Fragments endpoint.
I have the following request:
curl \ --get \ -H 'Accept: text/turtle' \ --data-urlencode 'predicate=http://www.w3.org/2000/01/rdf-schema#label' \ --data-urlencode 'subject=http://www.wikidata.org/entity/Q78' \ 'https://query.wikidata.org/bigdata/ldf'
This gives me the labels without language annotations. Do I miss something or why are the language tags absent?
wd:Q78 rdfs:label "巴塞爾"^^rdf:langString , "Basilia"^^rdf:langString , "Bazelo"^^rdf:langString , "Базел"^^rdf:langString , "Basel"^^rdf:langString , "Basileia"^^rdf:langString , "바젤"^^rdf:langString , "Bazel"^^rdf:langString , "Bâle"^^rdf:langString , "Bazylea"^^rdf:langString , "Базэль"^^rdf:langString , "בזל"^^rdf:langString , "巴塞尔"^^rdf:langString , "Basilea"^^rdf:langString , "बासेल"^^rdf:langString , "بازل"^^rdf:langString , "บาเซิล"^^rdf:langString , "ባዝል"^^rdf:langString , "Базель"^^rdf:langString .
I can do a similar SPARQL query which returns the labels:
SELECT * WHERE { wd:Q78 http://www.w3.org/2000/01/rdf-schema#label ?lang.
BIND(lang(?lang) as ?anno) }
In the docs (https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual#Standalone...), I found this example: https://query.wikidata.org/bigdata/ldf?subject=&predicate=http%3A%2F%2Fw... all triples that have English label "London"
Is there a way to get all labels for a certain language without specifying the label string itself? I tried wildcards but it did not work.
Any hint would be highly appreciated!
Thanks,
Tobias
-- SWITCH Tobias Schweizer, Data & Insights Werdstrasse 2, P.O. Box, 8021 Zurich, Switzerland phone +41 44 268 15 15, direct +41 44 268 15 17 tobias.schweizer@switch.chmailto:tobias.schweizer@switch.ch, www.switch.chhttp://www.switch.ch
On Tue, Sep 5, 2023 at 8:10 AM Tobias Schweizer tobias.schweizer@switch.ch wrote:
Hi there,
Hi!
Is there a way to get all labels for a certain language without specifying the label string itself? I tried wildcards but it did not work.
Filtering by language is sadly not possible using the LDF endpoint as it would require a FILTER sparql clause. Language not appearing in the LDF output is sadly a known limitation [0] of the current implementation. Also note that SPARQL/LDF is not the only way to extract information out of wikidata, have you considered using the wikidata wbgetentities API [1]? It can be used to extract labels in a certain language [2]. I suppose also that the upcoming wikidata REST api [3] will cover this use case as well.
David.
0: https://phabricator.wikimedia.org/T305983 1: https://www.wikidata.org/w/api.php?action=help&modules=wbgetentities 2: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q42&prop... 3: https://doc.wikimedia.org/Wikibase/master/js/rest-api/
Hi David,
Thanks a lot for your answer.
We can now obtain all required data like this: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q78&form...
The result contains the labels organised by language tags and geo data (P625) that we need as well. This is great!
I was also able to create a OAUTH 2.0 token (linked to my user).
What did not work, was token refreshing (https://www.wikidata.org/wiki/Wikidata:REST_API/Authentication#Non-owner-onl...).
I tried this:
curl --request POST \
--url https://www.wikidata.org/w/rest.php/w/rest.php/oauth2/access_token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data grant_type=client_credentials \
--data client_id=abc \
--data client_secret=xyz
I get the following response:
{"messageTranslations":{"en":"The requested relative path (/w/rest.php/oauth2/access_token) did not match any known handler"},"httpCode":404,"httpReason":"Not Found"}
Any idea what I am doing wrong?
Thanks again and kind regards,
Tobias
From: David Causse dcausse@wikimedia.org Reply to: A public mailing list about Wikimedia Search and Discovery projects discovery@lists.wikimedia.org Date: Tuesday, 5 September 2023 at 09:34 To: A public mailing list about Wikimedia Search and Discovery projects discovery@lists.wikimedia.org Subject: [discovery] Re: Language Annotations With Linked Data Fragments
On Tue, Sep 5, 2023 at 8:10 AM Tobias Schweizer tobias.schweizer@switch.ch wrote:
Hi there,
Hi!
Is there a way to get all labels for a certain language without specifying the label string itself? I tried wildcards but it did not work.
Filtering by language is sadly not possible using the LDF endpoint as it would require a FILTER sparql clause.
Language not appearing in the LDF output is sadly a known limitation [0] of the current implementation.
Also note that SPARQL/LDF is not the only way to extract information out of wikidata, have you considered using the wikidata wbgetentities API [1]?
It can be used to extract labels in a certain language [2]. I suppose also that the upcoming wikidata REST api [3] will cover this use case as well.
David.
0: https://phabricator.wikimedia.org/T305983
1: https://www.wikidata.org/w/api.php?action=help&modules=wbgetentities
2: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q42&prop...
On Tue, Sep 5, 2023 at 4:15 PM Tobias Schweizer tobias.schweizer@switch.ch wrote:
Hi David,
Thanks a lot for your answer.
We can now obtain all required data like this: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q78&form...
The result contains the labels organised by language tags and geo data (P625) that we need as well. This is great!
Glad to hear that this API suits your needs.
{"messageTranslations":{"en":"The requested relative path (/w/rest.php/oauth2/access_token) did not match any known handler"},"httpCode":404,"httpReason":"Not Found"}
Any idea what I am doing wrong?
I'm not knowledgeable enough to assist you with this problem, I'd suggest asking your question to the wikidata [0] or wikidata-tech [1] mailing-lists.
David.
0: https://lists.wikimedia.org/postorius/lists/wikidata.lists.wikimedia.org/ 1: https://lists.wikimedia.org/postorius/lists/wikidata-tech.lists.wikimedia.or...