qwikidata.entity module¶
Module for Wikidata Entities.
-
class
ClaimsMixin[source]¶ Bases:
objectMixin 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 returnReturn type: WikidataClaimGroup
-
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 returnReturn type: WikidataClaimGroup
-
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:
objectMixin for entities with labels, descriptions, and aliases.
See also
-
get_aliases(lang='en')[source]¶ Get alternative names for this entity in a specific language.
See: https://www.wikidata.org/wiki/Help:Aliases
Parameters: lang ( NewType()(LanguageCode,str)) – Find aliases in this language.Return type: List[str]
-
-
class
WikidataForm(form_dict)[source]¶ Bases:
qwikidata.entity.ClaimsMixinA 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:
-
class
WikidataItem(item_dict)[source]¶ Bases:
qwikidata.entity.LabelDescriptionAliasMixin,qwikidata.entity.ClaimsMixin,qwikidata.entity.EntityMixinClass 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.
-
get_sitelinks(prefix='enwiki')[source]¶ Get Wikimedia sitelinks for this item.
Parameters: prefix ( str) – filters to sitelinks that begin with prefix. can filter by language (e.g. “en”) or by language and site (e.g. “enwiki”).Returns: A dictionary with site names as keys and sitelink dictionaries as values. Return type: dict
-
-
class
WikidataLexeme(lexeme_dict)[source]¶ Bases:
qwikidata.entity.ClaimsMixin,qwikidata.entity.EntityMixinClass 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_forms()[source]¶ Get the set of forms assocaited with this Lexeme.
Return type: List[WikidataForm]
-
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
Parameters: lang ( NewType()(LanguageCode,str)) – Find the lemma in this language.Return type: str
-
get_senses()[source]¶ Get the set of senses assocaited with this Lexeme.
Return type: List[WikidataSense]
-
-
class
WikidataProperty(property_dict)[source]¶ Bases:
qwikidata.entity.LabelDescriptionAliasMixin,qwikidata.entity.ClaimsMixin,qwikidata.entity.EntityMixinClass 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:
qwikidata.entity.ClaimsMixinA 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’)