qwikidata.claim module¶
Module for Wikidata Claims (aka Statements).
- class WikidataClaim(claim_dict)[source]¶
Bases:
object
A claim aka statement about a Wikidata Entity.
From the Wikibase data model docs,
“Statements describe the claim of a statement and list references for this claim. Every Statement refers to one particular Entity, called the subject of the Statement. There is always one main Snak that forms the most important part of the statement. Moreover, there can be zero or more additional PropertySnaks that describe the Statement in more detail. These qualifier Snaks (or “qualifiers” for short) store additional information that does not directly refer to the subject (e.g., the time at which the main part of the statement was valid). References are provided as a list (the order is significant in some contexts, especially for displaying a main reference).”
This class can be initialized from an entity dictionary as,
>>> claim_dict = q42_dict['claims']['P551'][0] >>> wikidata_claim = WikidataClaim(claim_dict)
- Parameters
claim_dict (dict) – A dictionary representing a Wikidata claim. See the wikibase JSON data model docs for a description of the format.
- Variables
claim_id (str) – Unique id for this claim
property_id (PropertyId) – A Wikiata property id (e.g. “P551”)
claim_type (str) – One of [“claim”, “statement”] (statements may have references)
rank (str) – One of [“preferred”, “normal”, “deprecated”]
mainsnak (
WikidataSnak
) – The mainsnak of this claimqualifiers (collections.OrderedDict) – Maps property id to list of
WikidataQualifier
references (list) – A list of
WikidataReference
qualifiers_order (list) – The order of the property ids in qualifiers
- class WikidataClaimGroup(claim_list)[source]¶
Bases:
Sequence
A sequence of
WikidataClaim
instances with a common property id.For example the claim group for “Douglas Adams” (Q42) with property “residence” (P551) has three elements. This class can be initialized from an entity dictionary as,
>>> claim_group = WikidataClaimGroup(q42_dict['claims']['P551'])
- Parameters
claim_list (list) – A list of claim dictionaries representing a Wikidata claim group. See the wikibase JSON data model docs for a description of the format.
- class WikidataQualifier(qualifier_dict)[source]¶
Bases:
object
A qualifier about a claim about a Wikidata Entity.
See: https://www.wikidata.org/wiki/Help:Qualifiers
This class can be initialized from an entity dictionary as,
>>> qualifier_dict = q42_dict['claims']['P69'][0]['qualifiers']['P582'][0] >>> wikidata_qualifier = WikidataQualifier(qualifier_dict)
- Parameters
qualifier_dict (
QualifierDict
) – A dictionary representing a Wikidata qualifier. See the wikibase JSON data model docs for a description of the format.- Variables
qualifierhash (str) – Unique id for this qualifier
snak (WikidataSnak) – The snak for this qualifier
- class WikidataReference(reference_dict)[source]¶
Bases:
object
A reference about a claim about a Wikidata Entity.
See: https://www.wikidata.org/wiki/Help:Sources
This class can be initialized from an entity dictionary as,
>>> reference_dict = q42_dict['claims']['P69'][0]['references'][0] >>> wikidata_reference = WikidataReference(reference_dict)
- Parameters
reference_dict (
ReferenceDict
) – A dictionary representing a Wikidata reference. See the wikibase JSON data model docs for a description of the format.- Variables
referencehash (str) – Unique id for this reference
snaks (collections.OrderedDict) – Maps property id to list of
WikidataSnak