Quantity#

class wikibaseintegrator.datatypes.quantity.Quantity(amount=None, upper_bound=None, lower_bound=None, unit='1', wikibase_url=None, **kwargs)[source]#

Bases: BaseDataType

Implements the Wikibase data type for quantities

Constructor, calls the superclass BaseDataType

Parameters:
  • amount (str | int | float | None, default: None) – The amount value

  • upper_bound (str | int | float | None, default: None) – Upper bound of the value if it exists, e.g. for standard deviations

  • lower_bound (str | int | float | None, default: None) – Lower bound of the value if it exists, e.g. for standard deviations

  • unit (str | int, default: '1') – The unit item URL or the QID a certain amount has been measured in (https://www.wikidata.org/wiki/Wikidata:Units). The default is dimensionless, represented by a ‘1’

  • wikibase_url (str | None, default: None) – The default wikibase URL, used when the unit is only an ID like ‘Q2’. Use wbi_config[‘WIKIBASE_URL’] by default.

from_sparql_value(sparql_value)[source]#

Parse data returned by a SPARQL endpoint and set the value to the object

Parameters:

sparql_value (dict) – A SPARQL value composed of datatype, type and value

Return type:

Self

Returns:

True if the parsing is successful

get_sparql_value(**kwargs)[source]#
Return type:

str

parse_sparql_value(value, type='literal', unit='1')[source]#
Return type:

bool

set_value(amount=None, upper_bound=None, lower_bound=None, unit='1', wikibase_url=None)[source]#
Return type:

None

DTYPE = 'quantity'#
PTYPE = 'http://wikiba.se/ontology#Quantity'#