.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.engines.lingva Namespace Reference

Functions

 request (_query, params)
 
 response (resp)
 

Variables

dict about
 
str engine_type = 'online_dictionary'
 
list categories = ['general', 'translate']
 
str url = "https://lingva.thedaviddelta.com"
 
str search_url = "{url}/api/v1/{from_lang}/{to_lang}/{query}"
 

Detailed Description

Lingva (alternative Google Translate frontend)

Function Documentation

◆ request()

searx.engines.lingva.request ( _query,
params )

Definition at line 22 of file lingva.py.

22def request(_query, params):
23 params['url'] = search_url.format(
24 url=url, from_lang=params['from_lang'][1], to_lang=params['to_lang'][1], query=params['query']
25 )
26 return params
27
28

◆ response()

searx.engines.lingva.response ( resp)

Definition at line 29 of file lingva.py.

29def response(resp):
30 results = []
31
32 result = loads(resp.text)
33 info = result["info"]
34 from_to_prefix = "%s-%s " % (resp.search_params['from_lang'][1], resp.search_params['to_lang'][1])
35
36 if "typo" in info:
37 results.append({"suggestion": from_to_prefix + info["typo"]})
38
39 if 'definitions' in info: # pylint: disable=too-many-nested-blocks
40 for definition in info['definitions']:
41 if 'list' in definition:
42 for item in definition['list']:
43 if 'synonyms' in item:
44 for synonym in item['synonyms']:
45 results.append({"suggestion": from_to_prefix + synonym})
46
47 infobox = ""
48
49 for translation in info["extraTranslations"]:
50 for word in translation["list"]:
51 infobox += f"<dl><dt>{word['word']}</dt>"
52
53 for meaning in word["meanings"]:
54 infobox += f"<dd>{meaning}</dd>"
55
56 infobox += "</dl>"
57
58 results.append(
59 {
60 'infobox': result["translation"],
61 'content': infobox,
62 }
63 )
64
65 return results

Variable Documentation

◆ about

dict searx.engines.lingva.about
Initial value:
1= {
2 "website": 'https://lingva.ml',
3 "wikidata_id": None,
4 "official_api_documentation": 'https://github.com/thedaviddelta/lingva-translate#public-apis',
5 "use_official_api": True,
6 "require_api_key": False,
7 "results": 'JSON',
8}

Definition at line 6 of file lingva.py.

◆ categories

list searx.engines.lingva.categories = ['general', 'translate']

Definition at line 16 of file lingva.py.

◆ engine_type

str searx.engines.lingva.engine_type = 'online_dictionary'

Definition at line 15 of file lingva.py.

◆ search_url

str searx.engines.lingva.search_url = "{url}/api/v1/{from_lang}/{to_lang}/{query}"

Definition at line 19 of file lingva.py.

◆ url

str searx.engines.lingva.url = "https://lingva.thedaviddelta.com"

Definition at line 18 of file lingva.py.