Wikibase
MediaWiki Wikibase extension
|
Generate the conversion table for units, optionally filtered to units of a certain type. More...
Public Member Functions | |
__construct () | |
execute () | |
setBaseUri ( $uri) | |
convertDerivedUnit ( $unit, $convertUnits) | |
Convert unit that does not reduce to a coherent unit. | |
convertUnit ( $unit, $convertUnits, $coherentUnits, $unitUsage, &$reconvert) | |
Create conversion data for a single unit. | |
Public Attributes | |
$silent | |
Protected Member Functions | |
error ( $err, $die=0) | |
Private Member Functions | |
reduceUnits ( $reconvert, &$convertUnits) | |
Reduce units that are not in term of coherent units into coherent units. | |
formatJSON (array $convertUnits) | |
Format units as JSON. | |
getUnitUsage ( $min) | |
Get units that are used at least $min times. | |
getIDs ( $sparql, $item) | |
Get list of IDs from SPARQL. | |
getCoherentUnits ( $filter) | |
Get coherent units (those with a conversion factor of 1 to themselves). | |
getConvertableUnits ( $filter) | |
Retrieve the list of convertable units. | |
formatCSV (array $convertUnits) | |
Format units as CSV. | |
Private Attributes | |
$baseUri | |
$baseLen | |
$client | |
Generate the conversion table for units, optionally filtered to units of a certain type.
This script retrieves and emits the conversion data into coherent units. For instance, the millimetre is equal to 1/1000 of the coherent unit metre (also an SI base unit), while the ampere hour is equal to 3600 of the coherent unit coulomb, the product of the SI base units ampere and second.
Example usage: mwscript extensions/WikidataBuildResources/extensions/Wikibase/repo/maintenance/updateUnits.php –wiki wikidatawiki –base-uri http://www.wikidata.org/entity/ –unit-class Q1978718 > unitConversion.json
Wikibase\Repo\Maintenance\UpdateUnits::__construct | ( | ) |
Wikibase\Repo\Maintenance\UpdateUnits::convertDerivedUnit | ( | $unit, | |
$convertUnits ) |
Convert unit that does not reduce to a coherent unit.
string[] | $unit | |
array[] | $convertUnits | List of units already converted |
Wikibase\Repo\Maintenance\UpdateUnits::convertUnit | ( | $unit, | |
$convertUnits, | |||
$coherentUnits, | |||
$unitUsage, | |||
& | $reconvert ) |
Create conversion data for a single unit.
string[] | $unit | Unit data |
string[] | $convertUnits | Already converted data |
array[] | $coherentUnits | Ultimate target units |
string[] | null | $unitUsage | Unit usage data |
string[][] | &$reconvert | Array collecting units that require re-conversion later, due to their target unit not being coherent. |
|
protected |
string | $err | |
int | $die | If > 0, go ahead and die out using this int as the code |
Wikibase\Repo\Maintenance\UpdateUnits::execute | ( | ) |
|
private |
Format units as CSV.
array[] | $convertUnits |
|
private |
Format units as JSON.
array[] | $convertUnits |
|
private |
Get coherent units (those with a conversion factor of 1 to themselves).
string | $filter | Unit filter |
|
private |
Retrieve the list of convertable units.
string | $filter |
|
private |
Get list of IDs from SPARQL.
string | $sparql | Query |
string | $item | Variable name where IDs are stored |
|
private |
Get units that are used at least $min times.
We don't care about units that have been used less than 10 times, for now. Only top 200 will be returned (though so far we don't have that many).
int | $min | Minimal usage for the unit. |
|
private |
Reduce units that are not in term of coherent units into coherent units.
If some units are not reducible to coherent units, warnings are issued.
array | $reconvert | List of units to be reduced |
array | &$convertUnits | List of unit conversion configs, will be modified if it is possible to reduce the unit to coherent units. |
Wikibase\Repo\Maintenance\UpdateUnits::setBaseUri | ( | $uri | ) |
string | $uri |
|
private |
|
private |
|
private |
Wikibase\Repo\Maintenance\UpdateUnits::$silent |