qwikidata.entity module¶
Module for Wikidata Entities.
- class ClaimsMixin[source]¶
Bases:
object
Mixin for entities with top level claims (aka statements).
See: https://www.wikidata.org/wiki/Help:Statements
- get_claim_group(property_id)[source]¶
Get the claim group corresponding to a given property id.
- Parameters
property_id (
NewType()
(PropertyId
,str
)) – the string representing the property ID of the claim group to return- Return type
- get_claim_groups()[source]¶
Get all claim groups about this entity.
- Return type
Dict
[NewType()
(PropertyId
,str
),WikidataClaimGroup
]
- get_truthy_claim_group(property_id)[source]¶
Get truthy claims from the claim group corresponding to a given property id.
Truthy is defined in the Wikidata RDF dump format docs,
“Truthy statements represent statements that have the best non-deprecated rank for a given property. Namely, if there is a preferred statement for a property P, then only preferred statements for P will be considered truthy. Otherwise, all normal-rank statements for P are considered truthy.”
- Parameters
property_id (
NewType()
(PropertyId
,str
)) – the string representing the property ID of the claim group to return
- Return type
- get_truthy_claim_groups()[source]¶
Get all truthy claim groups about this entity.
Truthy is defined in the Wikidata RDF dump format docs,
“Truthy statements represent statements that have the best non-deprecated rank for a given property. Namely, if there is a preferred statement for a property P, then only preferred statements for P will be considered truthy. Otherwise, all normal-rank statements for P are considered truthy.”
- Return type
Dict
[NewType()
(PropertyId
,str
),WikidataClaimGroup
]
- class LabelDescriptionAliasMixin[source]¶
Bases:
object
Mixin for entities with labels, descriptions, and aliases.
See also
- class WikidataForm(form_dict)[source]¶
Bases:
ClaimsMixin
A form associated with a Wikidata Lexeme.
See: https://www.mediawiki.org/wiki/Extension:WikibaseLexeme/Data_Model#Form
This class can be initialized from a lexeme dictionary as,
>>> form_dict = l3354_dict['forms'][0] >>> wikidata_form = WikidataForm(form_dict)
- Parameters
form_dict (
FormDict
) – A dictionary representing a Wikidata Lexeme form.- Variables
- get_representation(lang='en')[source]¶
Get representation of this form in a given language.
See: https://www.mediawiki.org/wiki/Extension:WikibaseLexeme/Data_Model#Representation
- class WikidataItem(item_dict)[source]¶
Bases:
LabelDescriptionAliasMixin
,ClaimsMixin
,EntityMixin
Class for Wikidata Items.
- Parameters
item_dict (
ItemDict
) – A dictionary representation of a Wikidata Item. See the wikibase JSON data model docs for a description of the dictionary format.
See also
Wikidata docs on items,
Ways to generate item dictionaries within qwikidata.
- class WikidataLexeme(lexeme_dict)[source]¶
Bases:
ClaimsMixin
,EntityMixin
Class for Wikidata Lexeme.
- Parameters
lexeme_dict (
LexemeDict
) – A dictionary representation of a Wikidata Lexeme. See the wikibase Lexeme JSON data model docs for a description of the dictionary format.
See also
Wikidata docs on lexemes,
Ways to generate lexeme dictionaries within qwikidata.
- get_lemma(lang='en')[source]¶
Get lemma (primary name for this lexeme) in a specific language.
See: https://www.mediawiki.org/wiki/Extension:WikibaseLexeme/Data_Model#Lemma
- class WikidataProperty(property_dict)[source]¶
Bases:
LabelDescriptionAliasMixin
,ClaimsMixin
,EntityMixin
Class for Wikidata Properties.
- Parameters
property_dict (
PropertyDict
) – A dictionary representation of a Wikidata Property. See the wikibase JSON data model docs for a description of the dictionary format.
See also
Wikidata docs on properties,
Ways to generate property dictionaries within kwikimedia.
- class WikidataSense(sense_dict)[source]¶
Bases:
ClaimsMixin
A sense associated with a Wikidata Lexeme.
See: https://www.mediawiki.org/wiki/Extension:WikibaseLexeme/Data_Model#Sense
This class can be initialized from a lexeme dictionary as,
>>> sense_dict = l3354_dict['senses'][0] >>> wikidata_sense = WikidataSense(sense_dict)
- Parameters
sense_dict (
SenseDict
) – A dictionary representing a Wikidata Lexeme sense.- Variables
sense_id (str) – Unique id for this sense (e.g. ‘L3354-S1’)
- get_gloss(lang='en')[source]¶
Get gloss of this sense in a given language.
See: https://www.mediawiki.org/wiki/Extension:WikibaseLexeme/Data_Model#Gloss