.oO SearXNG Developer Documentation Oo.
|
Functions | |
symbol_to_si () | |
_parse_text_and_convert (search, from_query, to_query) | |
post_search (_request, search) | |
Variables | |
str | name = "Unit converter plugin" |
description = gettext("Convert between units") | |
bool | default_on = True |
str | plugin_id = "unit_converter" |
str | preference_section = "general" |
list | CONVERT_KEYWORDS = ["in", "to", "as"] |
str | RE_MEASURE |
list | ADDITIONAL_UNITS |
dict | ALIAS_SYMBOLS |
list | SYMBOL_TO_SI = [] |
A plugin for converting measured values from one unit to another unit (a unit converter). The plugin looks up the symbols (given in the query term) in a list of converters, each converter is one item in the list (compare :py:obj:`ADDITIONAL_UNITS`). If the symbols are ambiguous, the matching units of measurement are evaluated. The weighting in the evaluation results from the sorting of the :py:obj:`list of unit converters<symbol_to_si>`. Enable in ``settings.yml``: .. code:: yaml enabled_plugins: .. - 'Unit converter plugin'
|
protected |
Definition at line 174 of file unit_converter.py.
References searx.plugins.unit_converter.symbol_to_si().
Referenced by searx.plugins.unit_converter.post_search().
searx.plugins.unit_converter.post_search | ( | _request, | |
search ) |
Definition at line 245 of file unit_converter.py.
References searx.plugins.unit_converter._parse_text_and_convert().
searx.plugins.unit_converter.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 102 of file unit_converter.py.
Referenced by searx.plugins.unit_converter._parse_text_and_convert().
list searx.plugins.unit_converter.ADDITIONAL_UNITS |
Definition at line 48 of file unit_converter.py.
dict searx.plugins.unit_converter.ALIAS_SYMBOLS |
Definition at line 86 of file unit_converter.py.
list searx.plugins.unit_converter.CONVERT_KEYWORDS = ["in", "to", "as"] |
Definition at line 35 of file unit_converter.py.
bool searx.plugins.unit_converter.default_on = True |
Definition at line 30 of file unit_converter.py.
searx.plugins.unit_converter.description = gettext("Convert between units") |
Definition at line 29 of file unit_converter.py.
str searx.plugins.unit_converter.name = "Unit converter plugin" |
Definition at line 28 of file unit_converter.py.
str searx.plugins.unit_converter.plugin_id = "unit_converter" |
Definition at line 32 of file unit_converter.py.
str searx.plugins.unit_converter.preference_section = "general" |
Definition at line 33 of file unit_converter.py.
str searx.plugins.unit_converter.RE_MEASURE |
Definition at line 38 of file unit_converter.py.
list searx.plugins.unit_converter.SYMBOL_TO_SI = [] |
Definition at line 99 of file unit_converter.py.