format2wbi#
- wikibaseintegrator.wbi_helpers.format2wbi(entitytype, json_raw, allow_anonymous=True, wikibase_url=None, **kwargs)[source]#
Build a WikibaseIntegrator entity from a simplified JSON string: labels, descriptions and aliases by language, and the claims by property, each claim being a value or a list of values, and each value a string or a dict (e.g.
{"value": "First Author", "qualifiers": {"P1545": "1"}, "references": [{"P248": "Q5"}]},{"text": "...", "language": "en"},{"amount": "12", "unit": "Q11573"}). A reference is a dict of the snaks of one reference block.The datatype of the properties is retrieved from the instance (wbgetentities), and cached.
Warning
Experimental. This function (and its helper
_json2datatype()) is incomplete (the lemmas, forms and senses of a lexeme and the datatype of a property are not read, and a qualifier or a reference snak takes a single value per property). Its API and behaviour may change or be removed without notice.- Parameters:
entitytype (
str) – The type of the entity to build: ‘item’, ‘property’, ‘lexeme’ or ‘mediainfo’json_raw (
str) – The simplified JSON stringallow_anonymous (
bool, default:True) – Allow an anonymous lookup of the datatype of the properties. ‘True’ by default.wikibase_url (
str|None, default:None) – The Wikibase URL, used for the entity IDs of the values. Use wbi_config[‘WIKIBASE_URL’] by default.kwargs (
Any) – Extra parameters for mediawiki_api_call_helper(), used for the lookups (e.g. mediawiki_api_url, login)
- Return type:
- Returns:
The entity, not written to the instance