summaryrefslogtreecommitdiff
path: root/searx/search
diff options
context:
space:
mode:
authorArtikusHG <artiomoleynic@gmail.com>2022-12-11 17:45:47 +0200
committerArtikusHG <artiomoleynic@gmail.com>2022-12-16 21:07:39 +0200
commit1f8f8c1e91040fd10bacdc473b8d5f97dda6424e (patch)
tree30ed501e9a052ae4a9d81af45026af9a1deecfcf /searx/search
parenta6d870d5cfecfee78dcdd2a67cce318c894da2da (diff)
downloadsearxng-1f8f8c1e91040fd10bacdc473b8d5f97dda6424e.tar.gz
searxng-1f8f8c1e91040fd10bacdc473b8d5f97dda6424e.zip
Replace langdetect with fasttext
Diffstat (limited to 'searx/search')
-rw-r--r--searx/search/checker/impl.py16
1 files changed, 5 insertions, 11 deletions
diff --git a/searx/search/checker/impl.py b/searx/search/checker/impl.py
index 0705b6822..37f145e1e 100644
--- a/searx/search/checker/impl.py
+++ b/searx/search/checker/impl.py
@@ -10,12 +10,10 @@ from timeit import default_timer
from urllib.parse import urlparse
import re
-from langdetect import detect_langs
-from langdetect.lang_detect_exception import LangDetectException
import httpx
from searx import network, logger
-from searx.utils import gen_useragent
+from searx.utils import gen_useragent, detect_language
from searx.results import ResultContainer
from searx.search.models import SearchQuery, EngineRef
from searx.search.processors import EngineProcessor
@@ -208,14 +206,10 @@ class ResultContainerTests:
self.test_results.add_error(self.test_name, message, *args, '(' + sqstr + ')')
def _add_language(self, text: str) -> typing.Optional[str]:
- try:
- r = detect_langs(str(text)) # pylint: disable=E1101
- except LangDetectException:
- return None
-
- if len(r) > 0 and r[0].prob > 0.95:
- self.languages.add(r[0].lang)
- self.test_results.add_language(r[0].lang)
+ langStr = detect_language(text)
+ if langStr:
+ self.languages.add(langStr)
+ self.test_results.add_language(langStr)
return None
def _check_result(self, result):