Source code for kgdata.wikidata.models.wdentitylabel

from dataclasses import dataclass


[docs]@dataclass class WDEntityLabel: # contains only label & id of qnode __slots__ = ("id", "label") id: str label: str
[docs] @staticmethod def from_dict(o: dict): return WDEntityLabel(o["id"], o["label"])
[docs] def to_dict(self): return {"id": self.id, "label": self.label}
[docs] @staticmethod def from_wdentity_raw(o: dict): """Extract wdentity label from wdentity raw dictionary (which is passed to .from_dict to deserialize wdentity object)""" return WDEntityLabel( id=o["id"], label=o["label"]["lang2value"][o["label"]["lang"]] )