diff --git a/lib/adapter/question.py b/lib/adapter/question.py index 994156d..f872f00 100644 --- a/lib/adapter/question.py +++ b/lib/adapter/question.py @@ -12,8 +12,9 @@ import os import re from subprocess import Popen, PIPE -from polyglot.detect import Detector -from polyglot.detect.base import UnknownLanguage +#Language detetction disabled +#from polyglot.detect import Detector +#from polyglot.detect.base import UnknownLanguage from config import CONFIG from languages_data import SO_NAME @@ -83,25 +84,27 @@ class Question(UpstreamAdapter): topic = " ".join(topic_words) lang = 'en' - try: - query_text = topic # " ".join(topic) - query_text = re.sub('^[^/]*/+', '', query_text.rstrip('/')) - query_text = re.sub('/[0-9]+$', '', query_text) - query_text = re.sub('/[0-9]+$', '', query_text) - detector = Detector(query_text) - supposed_lang = detector.languages[0].code - if len(topic_words) > 2 \ - or supposed_lang in ['az', 'ru', 'uk', 'de', 'fr', 'es', 'it', 'nl']: - lang = supposed_lang - if supposed_lang.startswith('zh_') or supposed_lang == 'zh': - lang = 'zh' - elif supposed_lang.startswith('pt_'): - lang = 'pt' - if supposed_lang in ['ja', 'ko']: - lang = supposed_lang - except UnknownLanguage: - print("Unknown language (%s)" % query_text) + # Question language detection disabled + # try: + # query_text = topic # " ".join(topic) + # query_text = re.sub('^[^/]*/+', '', query_text.rstrip('/')) + # query_text = re.sub('/[0-9]+$', '', query_text) + # query_text = re.sub('/[0-9]+$', '', query_text) + # detector = Detector(query_text) + # supposed_lang = detector.languages[0].code + # if len(topic_words) > 2 \ + # or supposed_lang in ['az', 'ru', 'uk', 'de', 'fr', 'es', 'it', 'nl']: + # lang = supposed_lang + # if supposed_lang.startswith('zh_') or supposed_lang == 'zh': + # lang = 'zh' + # elif supposed_lang.startswith('pt_'): + # lang = 'pt' + # if supposed_lang in ['ja', 'ko']: + # lang = supposed_lang + + # except UnknownLanguage: + # print("Unknown language (%s)" % query_text) if lang != 'en': topic = ['--human-language', lang, topic] diff --git a/requirements.txt b/requirements.txt index 885e58e..ac0da4a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,10 +9,13 @@ redis colored langdetect cffi -polyglot -PyICU -pycld2 colorama pyyaml python-Levenshtein pylint + +#Disable language detection feature +# +#polyglot +#PyICU +#pycld2