The current implementation of the LiteralElement and URIElement classes provide directly methods to translate to wdi datatypes and classes. For example:
class URIElement(TripleElement):
...
@property
def wdi_class(self) -> Union[Type[WDItemID], Type[WDProperty]]:
""" Returns the wikidataintegrator class of the element.
"""
assert self.etype in self.VALID_ETYPES
return WDItemID if self.etype == 'item' else WDProperty
@property
def wdi_dtype(self) -> str:
""" Returns the wikidataintegrator DTYPE of this element.
"""
return self.wdi_class.DTYPE
def to_wdi_datatype(self, **kwargs) -> Union[WDItemID, WDProperty]:
return self.wdi_class(value=self.id, **kwargs)
This code should be refactored, so the wikidataintegrator objects are totally decoupled from the TripleElements. For example, the mappings module could be used to provide functions that can convert from one type to the other.
The current implementation of the LiteralElement and URIElement classes provide directly methods to translate to wdi datatypes and classes. For example:
This code should be refactored, so the wikidataintegrator objects are totally decoupled from the TripleElements. For example, the mappings module could be used to provide functions that can convert from one type to the other.