1

I am aware that you can download a Wikidata dump file from here

But is it possible to only include results for a specific language?I have in the past worked with a json dump file and used python to parse it as well as this library to get the labels of properties such as P106 in english ("occupation"). But is this something that can be done for other languages as well?

2
  • Are you only after property labels in the target language, or more general content? Jul 19, 2022 at 18:50
  • The properties and their values would be useful for me
    – Pasqual
    Jul 20, 2022 at 9:16

2 Answers 2

1

The dump files should contain all language content - Wikidata does not have different language editions and so there are no language-specific dumps. In general all items and properties exist in all languages - the difference is in the labels which are applied to them. (There are a few plain-text fields which are language specific, but not for things like "occupation")

The python library you mention is not one I'm familiar with, and it's confusing me a bit - WD doesn't give any particular priority or special status to English, but this only seems to return English labels/descriptions, which suggests to me that maybe it has hard coded a language selector somewhere. I wonder if you might be able to tinker with the code and just switch eg 'fr' for 'en' somewhere. I couldn't work out where that is set, though.

Alternatively, rather than use this API wrapper to get labels for a given property/item, you could try using and parsing the Wikidata query service results, or the Wikidata MediaWiki API - this will give you much finer control over languages returned etc. The WD data access page gives an indication of the various endpoints.

It depends a little on what you're trying to do - for "all properties and values on a specific item with labels in a specific language", the MediaWiki API is probably best; for "all values of a single property across all items with labels in a specific language", the query service is best.

0

Here's how to use the WikiData package you are using to retrieve the data in French (it's in Entity.data):

>>> # pip install WikiData
>>> entity = wikidata.client.Client().get('Q1')
>>> entity.label
'universe'
>>> entity.data['descriptions']['fr']
{'language': 'fr',
 'value': 'ensemble de tout ce qui existe : énergie, espace, temps et matière'}
>>> entity.data['labels']['fr']
{'language': 'fr', 'value': 'univers'}

All the other multilingual Entity attributes/properties like claims and sitelinks are also available within the Entity.data dict (actually a multidict):

>>> list(entity.data.keys())
['pageid',
 'ns',
 'title',
 'lastrevid',
 'modified',
 'type',
 'id',
 'labels',
 'descriptions',
 'aliases',
 'claims',
 'sitelinks']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.