Entity

class LexData.entity.Entity(repo: LexData.wikidatasession.WikidataSession)

Bases: dict

Base class for all types of entities – currently: Lexeme, Form, Sense. Not yet implemented: Item, Property.

In Wikidata all entities are stored in JSON format. Since JSON can be mapped naturally to python dictionaries a lexeme can be represented by a dictionary. All changes to an entity are changes to values in this dictionary. To allow accessing all information in an entity while at the same time making common operations as easily as possible, all entities are handled by classes that inherit from dict. You can access arbitrary parts of the lexeme with the usual dictionary syntax lexeme[key] or with the function dict.get().

If you modify the content of the dictionary you have to upload the new version of the entity to Wikidata. If you use the functions of the class the data is uploaded automatically.

addClaims(claims: Union[List[LexData.claim.Claim], Dict[str, List[str]]])

Add claims to the entity.

Parameters

claims

The claims to be added to the entity.

There are two possibilities for this:

  • A list of Objects of type Claim

    Example: [Claim(propertyId="P31", value="Q1")]

  • A dictionary with the property id as key and lists of string formated entity ids as values.

    Example: {"P31": ["Q1", "Q2"]}

The first supports all datatypes, whereas the later currently only supports datatypes of kind Entity.

property claims

All claims of the entity

Return type

Dict[str, List[Claim]]

property id