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

Namespaces

namespace  random
 
namespace  statistics
 

Functions

 load_answerers ()
 
 get_answerers_by_keywords (answerers)
 
 ask (query)
 

Variables

 answerers_dir = dirname(realpath(__file__))
 
 answerers = load_answerers()
 
 answerers_by_keywords = get_answerers_by_keywords(answerers)
 

Function Documentation

◆ ask()

searx.answerers.ask ( query)

Definition at line 36 of file __init__.py.

36def ask(query):
37 results = []
38 query_parts = list(filter(None, query.query.split()))
39
40 if not query_parts or query_parts[0] not in answerers_by_keywords:
41 return results
42
43 for answerer in answerers_by_keywords[query_parts[0]]:
44 result = answerer(query)
45 if result:
46 results.append(result)
47 return results
48
49

◆ get_answerers_by_keywords()

searx.answerers.get_answerers_by_keywords ( answerers)

Definition at line 27 of file __init__.py.

27def get_answerers_by_keywords(answerers): # pylint:disable=redefined-outer-name
28 by_keyword = defaultdict(list)
29 for answerer in answerers:
30 for keyword in answerer.keywords:
31 for keyword in answerer.keywords:
32 by_keyword[keyword].append(answerer.answer)
33 return by_keyword
34
35

◆ load_answerers()

searx.answerers.load_answerers ( )

Definition at line 14 of file __init__.py.

14def load_answerers():
15 answerers = [] # pylint: disable=redefined-outer-name
16
17 for filename in listdir(answerers_dir):
18 if not isdir(join(answerers_dir, filename)) or filename.startswith('_'):
19 continue
20 module = load_module('answerer.py', join(answerers_dir, filename))
21 if not hasattr(module, 'keywords') or not isinstance(module.keywords, tuple) or not module.keywords:
22 sys.exit(2)
23 answerers.append(module)
24 return answerers
25
26

Variable Documentation

◆ answerers

searx.answerers.answerers = load_answerers()

Definition at line 50 of file __init__.py.

◆ answerers_by_keywords

searx.answerers.answerers_by_keywords = get_answerers_by_keywords(answerers)

Definition at line 51 of file __init__.py.

◆ answerers_dir

searx.answerers.answerers_dir = dirname(realpath(__file__))

Definition at line 11 of file __init__.py.