Update the conversion table for units.
More...
|
| reduceUnits ( $reconvert, &$convertUnits) |
| Reduce units that are not in term of base units into base 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.
|
|
| getBaseUnits ( $filter) |
| Get base units.
|
|
| getConvertableUnits ( $filter) |
| Retrieve the list of convertable units.
|
|
| formatCSV (array $convertUnits) |
| Format units as CSV.
|
|
Update the conversion table for units.
Base unit types for Wikidata: Q223662,Q208469 SI base unit,SI derived unit TODO: add support to non-SI units Example run: mwscript extensions/WikidataBuildResources/extensions/Wikibase/repo/maintenance/updateUnits.php –wiki wikidatawiki –base-unit-types Q223662,Q208469 –base-uri http://www.wikidata.org/entity/ –unit-class Q1978718 > unitConversion.json
- Copyright
- GPL-2.0-or-later
- Author
- Stas Malyshev
◆ __construct()
Wikibase\Repo\Maintenance\UpdateUnits::__construct |
( |
| ) |
|
◆ convertDerivedUnit()
Wikibase\Repo\Maintenance\UpdateUnits::convertDerivedUnit |
( |
|
$unit, |
|
|
|
$convertUnits |
|
) |
| |
Convert unit that does not reduce to a basic unit.
- Parameters
-
string[] | $unit | |
array[] | $convertUnits | List of units already converted |
- Returns
- string[]|null Converted data for the unit or null if no conversion possible.
◆ convertUnit()
Wikibase\Repo\Maintenance\UpdateUnits::convertUnit |
( |
|
$unit, |
|
|
|
$convertUnits, |
|
|
|
$baseUnits, |
|
|
|
$unitUsage, |
|
|
& |
$reconvert |
|
) |
| |
Create conversion data for a single unit.
- Parameters
-
string[] | $unit | Unit data |
string[] | $convertUnits | Already converted data |
array[] | $baseUnits | Base unit list |
string[] | null | $unitUsage | Unit usage data |
string[][] | &$reconvert | Array collecting units that require re-conversion later, due to their target unit not being base. |
- Returns
- string[]|null Produces conversion data for the unit or null if not possible.
◆ error()
Wikibase\Repo\Maintenance\UpdateUnits::error |
( |
|
$err, |
|
|
|
$die = 0 |
|
) |
| |
|
protected |
- Parameters
-
string | $err | |
int | $die | If > 0, go ahead and die out using this int as the code |
◆ execute()
Wikibase\Repo\Maintenance\UpdateUnits::execute |
( |
| ) |
|
◆ formatCSV()
Wikibase\Repo\Maintenance\UpdateUnits::formatCSV |
( |
array |
$convertUnits | ) |
|
|
private |
Format units as CSV.
- Parameters
-
- Returns
- string
◆ formatJSON()
Wikibase\Repo\Maintenance\UpdateUnits::formatJSON |
( |
array |
$convertUnits | ) |
|
|
private |
Format units as JSON.
- Parameters
-
- Returns
- string
◆ getBaseUnits()
Wikibase\Repo\Maintenance\UpdateUnits::getBaseUnits |
( |
|
$filter | ) |
|
|
private |
Get base units.
- Parameters
-
- Returns
- array[]
◆ getConvertableUnits()
Wikibase\Repo\Maintenance\UpdateUnits::getConvertableUnits |
( |
|
$filter | ) |
|
|
private |
Retrieve the list of convertable units.
- Parameters
-
- Returns
- array[]|false List of units that can be converted
◆ getIDs()
Wikibase\Repo\Maintenance\UpdateUnits::getIDs |
( |
|
$sparql, |
|
|
|
$item |
|
) |
| |
|
private |
Get list of IDs from SPARQL.
- Parameters
-
string | $sparql | Query |
string | $item | Variable name where IDs are stored |
- Returns
- string[] List of entity ID strings
◆ getUnitUsage()
Wikibase\Repo\Maintenance\UpdateUnits::getUnitUsage |
( |
|
$min | ) |
|
|
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).
- Parameters
-
int | $min | Minimal usage for the unit. |
- Returns
- string[] Array of ['unit' => Q-id, 'c' => count]
◆ reduceUnits()
Wikibase\Repo\Maintenance\UpdateUnits::reduceUnits |
( |
|
$reconvert, |
|
|
& |
$convertUnits |
|
) |
| |
|
private |
Reduce units that are not in term of base units into base units.
If some units are not reducible to base units, warning will be issued.
- Parameters
-
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 base units. |
◆ setBaseUri()
Wikibase\Repo\Maintenance\UpdateUnits::setBaseUri |
( |
|
$uri | ) |
|
◆ $baseLen
Wikibase\Repo\Maintenance\UpdateUnits::$baseLen |
|
private |
◆ $baseUri
Wikibase\Repo\Maintenance\UpdateUnits::$baseUri |
|
private |
◆ $client
Wikibase\Repo\Maintenance\UpdateUnits::$client |
|
private |
◆ $silent
Wikibase\Repo\Maintenance\UpdateUnits::$silent |
The documentation for this class was generated from the following file: