.oO SearXNG Developer Documentation Oo.
|
Classes | |
class | Beaufort |
Functions | |
float | convert_from_si (str si_name, str symbol, float|int value) |
float | convert_to_si (str si_name, str symbol, float|int value) |
units_by_si_name (si_name) | |
symbol_to_si () | |
fetch_units () | |
Variables | |
list | __all__ = ["convert_from_si", "convert_to_si", "symbol_to_si"] |
list | ADDITIONAL_UNITS |
dict | ALIAS_SYMBOLS |
list | SYMBOL_TO_SI = [] |
dict | UNITS_BY_SI_NAME = {} |
int | pos_symbol = 0 |
int | pos_si_name = 1 |
int | pos_from_si = 2 |
int | pos_to_si = 3 |
str | SARQL_REQUEST |
Unit conversion on the basis of `SPARQL/WIKIDATA Precision, Units and Coordinates`_ .. _SPARQL/WIKIDATA Precision, Units and Coordinates: https://en.wikibooks.org/wiki/SPARQL/WIKIDATA_Precision,_Units_and_Coordinates#Quantities
float searx.wikidata_units.convert_from_si | ( | str | si_name, |
str | symbol, | ||
float | int | value ) |
Definition at line 120 of file wikidata_units.py.
References units_by_si_name().
float searx.wikidata_units.convert_to_si | ( | str | si_name, |
str | symbol, | ||
float | int | value ) |
Definition at line 129 of file wikidata_units.py.
References units_by_si_name().
searx.wikidata_units.fetch_units | ( | ) |
Fetch units from Wikidata. Function is used to update persistence of :py:obj:`searx.data.WIKIDATA_UNITS`.
Definition at line 270 of file wikidata_units.py.
searx.wikidata_units.symbol_to_si | ( | ) |
Generates a list of tuples, each tuple is a measure unit and the fields in the tuple are: 0. Symbol of the measure unit (e.g. 'mi' for measure unit 'miles' Q253276) 1. SI name of the measure unit (e.g. Q11573 for SI unit 'metre') 2. Factor to get SI value from measure unit (e.g. 1mi is equal to SI 1m multiplied by 1609.344) 3. Factor to get measure value from from SI value (e.g. SI 100m is equal to 100mi divided by 1609.344) The returned list is sorted, the first items are created from ``WIKIDATA_UNITS``, the second group of items is build from :py:obj:`ADDITIONAL_UNITS` and items created from :py:obj:`ALIAS_SYMBOLS`. If you search this list for a symbol, then a match with a symbol from Wikidata has the highest weighting (first hit in the list), followed by the symbols from the :py:obj:`ADDITIONAL_UNITS` and the lowest weighting is given to the symbols resulting from the aliases :py:obj:`ALIAS_SYMBOLS`.
Definition at line 166 of file wikidata_units.py.
Referenced by units_by_si_name().
searx.wikidata_units.units_by_si_name | ( | si_name | ) |
Definition at line 138 of file wikidata_units.py.
References symbol_to_si().
Referenced by convert_from_si(), and convert_to_si().
|
private |
Definition at line 10 of file wikidata_units.py.
list searx.wikidata_units.ADDITIONAL_UNITS |
Definition at line 58 of file wikidata_units.py.
dict searx.wikidata_units.ALIAS_SYMBOLS |
Definition at line 102 of file wikidata_units.py.
int searx.wikidata_units.pos_from_si = 2 |
Definition at line 161 of file wikidata_units.py.
int searx.wikidata_units.pos_si_name = 1 |
Definition at line 160 of file wikidata_units.py.
int searx.wikidata_units.pos_symbol = 0 |
Definition at line 159 of file wikidata_units.py.
int searx.wikidata_units.pos_to_si = 3 |
Definition at line 162 of file wikidata_units.py.
str searx.wikidata_units.SARQL_REQUEST |
Definition at line 250 of file wikidata_units.py.
list searx.wikidata_units.SYMBOL_TO_SI = [] |
Definition at line 116 of file wikidata_units.py.
dict searx.wikidata_units.UNITS_BY_SI_NAME = {} |
Definition at line 117 of file wikidata_units.py.