LexemeEntity#
- class wikibaseintegrator.entities.lexeme.LexemeEntity(lemmas=None, lexical_category=None, language=None, forms=None, senses=None, **kwargs)[source]#
Bases:
BaseEntity- add_claims(claims, action_if_exists=ActionIfExists.APPEND_OR_REPLACE)#
- Parameters:
claims (
Claim|list[Claim] |Claims) – A Claim, list of Claim or just a Claims object to add to the claims of this entity.action_if_exists (
ActionIfExists, default:ActionIfExists.APPEND_OR_REPLACE) – What to do when the property already has claims. Two claims are equal when they have the same property, value and qualifiers (the rank and the references are not compared). Defaults to APPEND_OR_REPLACE. APPEND_OR_REPLACE: Add the new claim if no equal claim exists. Otherwise, update the equal claim in place (same statement) instead of adding a duplicate: it takes the rank of the new claim if set (not normal), and its references if it has some (they replace the existing references). The other claims of the property are kept. MERGE_REFS_OR_APPEND: Add the new claim if no equal claim exists. Otherwise, add the references of the new claim missing from the equal claim. The other claims of the property are kept. FORCE_APPEND: Always add the new claim, even if an equal claim exists (duplicate statement). KEEP: Add the new claim only if the property has no claim yet, otherwise do nothing. REPLACE_ALL: Remove the claims of the property that are not equal to one of the new claims, then add the new claims not already present. The equal claims are kept as they are.
- Return type:
- Returns:
Return the updated entity object.
- clear(**kwargs)#
Use the clear parameter of wbeditentity API call to clear the content of the entity. The entity will be updated with an empty dictionary.
- delete(login=None, allow_anonymous=False, is_bot=None, **kwargs)#
Delete the current entity. Use the pageid first if available and fallback to the page title.
- Parameters:
login (
_Login|None, default:None) – A wbi_login.Login instanceallow_anonymous (
bool, default:False) – Allow an unidentified edit to the MediaWiki API (default False)is_bot (
bool|None, default:None) – Flag the edit as a botreason – Reason for the deletion. If not set, an automatically generated reason will be used.
deletetalk – Delete the talk page, if it exists.
kwargs (
Any) – Any additional keyword arguments to pass to mediawiki_api_call_helper and requests.request
- Return type:
- Returns:
The data returned by the API as a dictionary
- get(entity_id=None, **kwargs)[source]#
Request the MediaWiki API to get data for the entity specified in argument.
- Parameters:
- Return type:
- Returns:
a LexemeEntity instance
- get_claims(property, login=None, allow_anonymous=True, is_bot=None, **kwargs)#
Load the claims of a property from the Wikibase instance. They replace the claims of this property already loaded, unsaved changes included, so calling it again refreshes them instead of duplicating them.
- Parameters:
- Return type:
- Returns:
This entity
- write(**kwargs)[source]#
Write the LexemeEntity data to the Wikibase instance and return the LexemeEntity object returned by the instance.
- Parameters:
data – The serialized object that is used as the data source. A newly created entity will be assigned an ‘id’.
summary – A summary of the edit
login – A login instance
allow_anonymous – Force a check if the query can be anonymous or not
clear – Clear the existing entity before updating
is_bot – Add the bot flag to the query
kwargs (
Any) – More arguments for Python requests
- Return type:
- Returns:
an LexemeEntity of the response from the instance
- write_form(form, login=None, allow_anonymous=False, is_bot=None, **kwargs)[source]#
Add a single Form to the Lexeme with the wbladdform action.
Contrary to write(), only the Form is sent to the Wikibase instance, the rest of the Lexeme is left untouched.
- Parameters:
form (
Form) – The Form to add. It must be a new Form, without an id.login (
_Login|None, default:None) – A login instanceallow_anonymous (
bool, default:False) – Force a check if the query can be anonymous or notis_bot (
bool|None, default:None) – Add the bot flag to the querykwargs (
Any) – More arguments for lexeme_add_form and Python requests
- Return type:
- Returns:
The id of the newly created Form, e.g. L10-F2
- write_forms(**kwargs)[source]#
Add all the new Forms of the Lexeme, one wbladdform action per Form. The Forms already existing on the Wikibase instance are skipped.
- write_required(base_filter, action_if_exists=ActionIfExists.REPLACE_ALL, **kwargs)#
- Return type:
- write_sense(sense, login=None, allow_anonymous=False, is_bot=None, **kwargs)[source]#
Add a single Sense to the Lexeme with the wbladdsense action.
Contrary to write(), only the Sense is sent to the Wikibase instance, the rest of the Lexeme is left untouched.
- Parameters:
sense (
Sense) – The Sense to add. It must be a new Sense, without an id.login (
_Login|None, default:None) – A login instanceallow_anonymous (
bool, default:False) – Force a check if the query can be anonymous or notis_bot (
bool|None, default:None) – Add the bot flag to the querykwargs (
Any) – More arguments for lexeme_add_sense and Python requests
- Return type:
- Returns:
The id of the newly created Sense, e.g. L10-S2
- write_senses(**kwargs)[source]#
Add all the new Senses of the Lexeme, one wbladdsense action per Sense. The Senses already existing on the Wikibase instance and the Senses marked as removed are skipped.
- ETYPE = 'lexeme'#
- property api: WikibaseIntegrator#