.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.search.processors.online_dictionary Namespace Reference

Classes

class  DictParams
class  OnlineDictionaryProcessor
class  OnlineDictParams

Functions

FromToType|None _get_lang_descr (str lang)

Variables

 search_syntax = re.compile(r".*?([a-z]+)-([a-z]+) (.+)$", re.I)
FromToType = tuple[bool, str, str]

Detailed Description

Processor used for ``online_dictionary`` engines.

Function Documentation

◆ _get_lang_descr()

FromToType | None searx.search.processors.online_dictionary._get_lang_descr ( str lang)
protected
Returns language's code and language's english name if argument ``lang``
describes a language known by SearXNG, otherwise ``None``.

Examples:

.. code:: python

    >>> _get_lang_descr("zz")
    None
    >>> _get_lang_descr("uk")
    (True, "uk", "ukrainian")
    >>> _get_lang_descr(b"uk")
    (True, "uk", "ukrainian")
    >>> _get_lang_descr("en")
    (True, "en", "english")
    >>> _get_lang_descr("Español")
    (True, "es", "spanish")
    >>> _get_lang_descr("Spanish")
    (True, "es", "spanish")

Definition at line 70 of file online_dictionary.py.

70def _get_lang_descr(lang: str) -> FromToType | None:
71 """Returns language's code and language's english name if argument ``lang``
72 describes a language known by SearXNG, otherwise ``None``.
73
74 Examples:
75
76 .. code:: python
77
78 >>> _get_lang_descr("zz")
79 None
80 >>> _get_lang_descr("uk")
81 (True, "uk", "ukrainian")
82 >>> _get_lang_descr(b"uk")
83 (True, "uk", "ukrainian")
84 >>> _get_lang_descr("en")
85 (True, "en", "english")
86 >>> _get_lang_descr("Español")
87 (True, "es", "spanish")
88 >>> _get_lang_descr("Spanish")
89 (True, "es", "spanish")
90
91 """
92 lang = lang.lower()
93 is_abbr = len(lang) == 2
94 if is_abbr:
95 for l in sxng_locales:
96 if l[0][:2] == lang:
97 return (True, l[0][:2], l[3].lower())
98 return None
99 for l in sxng_locales:
100 if l[1].lower() == lang or l[3].lower() == lang:
101 return (True, l[0][:2], l[3].lower())
102 return None

Referenced by searx.search.processors.online_dictionary.OnlineDictionaryProcessor.get_params().

Here is the caller graph for this function:

Variable Documentation

◆ FromToType

t searx.search.processors.online_dictionary.FromToType = tuple[bool, str, str]

Definition at line 16 of file online_dictionary.py.

◆ search_syntax

searx.search.processors.online_dictionary.search_syntax = re.compile(r".*?([a-z]+)-([a-z]+) (.+)$", re.I)

Definition at line 13 of file online_dictionary.py.