Claim¶
-
class
LexData.
Claim
(claim: Optional[Dict[str, Any]] = None, propertyId: Optional[str] = None, value: Optional[Any] = None)¶ Bases:
dict
Wrapper around a dict to represent a Claim
There are two types of Claim objects:
Claims that where received from an existing entity.
Claims that where created by the user by Claim(propertyId, value) and have not yet been uploaded to Wikidata. These are called ‘Detached Claims’, since they don’t belong to any entity. They don’t have an id nor an hash. They can be added to an entity by the function Entity.addClaims().
Currently modifications on both types of claims can’t be uploaded, except by use of the low level API call Lexeme.update_from_json().
-
property
numeric_rank
¶ Return the rank of the claim as integer.
Returns a integer representation of the claims rank: * 0 for normal rank * 1 for preferred rank * -1 for deprecated rank
Using this allows for easier comparing and filtering.
- Example
>>> if claim.numeric_rank >= 0: >>> return claim.pure_value >>> else: >>> logger.log("No valid value found.") >>> return None
- Return type
int
-
property
property
¶ Return the id of the property of the claim. Example: “P27”
- Return type
str
-
property_decorator
¶ alias of
builtins.property
-
property
pure_value
¶ Return just the ‘pure’ value, what this is depends on the type of the value:
wikibase-entity: the id as string, including ‘L/Q/P’-prefix
string: the string
manolingualtext: the text as string
quantity: the amount as float
time: the timestamp as string in format ISO 8601
globecoordinate: tuple of latitude and longitude as floats
Be aware that for most types this is not the full information stored in the value.
-
property
rank
¶ Return the rank of the claim.
The rank is one of: * “normal” * “preferred” * “deprecated”
- Return type
str
-
property
type
¶ Return the data type of the claim as string.
Currently the following datatypes are used in Wikidata: * commonsMedia * geo-shape * globe-coordinate * math * monolingualtext * musical-notation * quantity * string * tabular-data * time * url * wikibase-form * wikibase-item * wikibase-lexeme * wikibase-property * wikibase-sense
- Return type
str
-
property
value
¶ Return the value of the claim. The return type depends on the data type.