|
12 | 12 | import re |
13 | 13 | from subprocess import Popen, PIPE |
14 | 14 |
|
15 | | -from polyglot.detect import Detector |
16 | | -from polyglot.detect.base import UnknownLanguage |
17 | | - |
18 | 15 | from config import CONFIG |
19 | 16 | from languages_data import SO_NAME |
20 | 17 | from .upstream import UpstreamAdapter |
@@ -81,32 +78,7 @@ def _get_page(self, topic, request_options=None): |
81 | 78 | topic_words = topic.split() |
82 | 79 |
|
83 | 80 | topic = " ".join(topic_words) |
84 | | - |
85 | | - lang = 'en' |
86 | | - try: |
87 | | - query_text = topic # " ".join(topic) |
88 | | - query_text = re.sub('^[^/]*/+', '', query_text.rstrip('/')) |
89 | | - query_text = re.sub('/[0-9]+$', '', query_text) |
90 | | - query_text = re.sub('/[0-9]+$', '', query_text) |
91 | | - detector = Detector(query_text) |
92 | | - supposed_lang = detector.languages[0].code |
93 | | - if len(topic_words) > 2 \ |
94 | | - or supposed_lang in ['az', 'ru', 'uk', 'de', 'fr', 'es', 'it', 'nl']: |
95 | | - lang = supposed_lang |
96 | | - if supposed_lang.startswith('zh_') or supposed_lang == 'zh': |
97 | | - lang = 'zh' |
98 | | - elif supposed_lang.startswith('pt_'): |
99 | | - lang = 'pt' |
100 | | - if supposed_lang in ['ja', 'ko']: |
101 | | - lang = supposed_lang |
102 | | - |
103 | | - except UnknownLanguage: |
104 | | - print("Unknown language (%s)" % query_text) |
105 | | - |
106 | | - if lang != 'en': |
107 | | - topic = ['--human-language', lang, topic] |
108 | | - else: |
109 | | - topic = [topic] |
| 81 | + topic = [topic] |
110 | 82 |
|
111 | 83 | cmd = [CONFIG["path.internal.bin.upstream"]] + topic |
112 | 84 | proc = Popen(cmd, stdin=open(os.devnull, "r"), stdout=PIPE, stderr=PIPE) |
|
0 commit comments