|
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 |
@@ -83,40 +80,7 @@ def _get_page(self, topic, request_options=None): |
83 | 80 | topic_words = topic.split() |
84 | 81 |
|
85 | 82 | topic = " ".join(topic_words) |
86 | | - |
87 | | - lang = "en" |
88 | | - try: |
89 | | - query_text = topic # " ".join(topic) |
90 | | - query_text = re.sub("^[^/]*/+", "", query_text.rstrip("/")) |
91 | | - query_text = re.sub("/[0-9]+$", "", query_text) |
92 | | - query_text = re.sub("/[0-9]+$", "", query_text) |
93 | | - detector = Detector(query_text) |
94 | | - supposed_lang = detector.languages[0].code |
95 | | - if len(topic_words) > 2 or supposed_lang in [ |
96 | | - "az", |
97 | | - "ru", |
98 | | - "uk", |
99 | | - "de", |
100 | | - "fr", |
101 | | - "es", |
102 | | - "it", |
103 | | - "nl", |
104 | | - ]: |
105 | | - lang = supposed_lang |
106 | | - if supposed_lang.startswith("zh_") or supposed_lang == "zh": |
107 | | - lang = "zh" |
108 | | - elif supposed_lang.startswith("pt_"): |
109 | | - lang = "pt" |
110 | | - if supposed_lang in ["ja", "ko"]: |
111 | | - lang = supposed_lang |
112 | | - |
113 | | - except UnknownLanguage: |
114 | | - print("Unknown language (%s)" % query_text) |
115 | | - |
116 | | - if lang != "en": |
117 | | - topic = ["--human-language", lang, topic] |
118 | | - else: |
119 | | - topic = [topic] |
| 83 | + topic = [topic] |
120 | 84 |
|
121 | 85 | cmd = [CONFIG["path.internal.bin.upstream"]] + topic |
122 | 86 | proc = Popen(cmd, stdin=open(os.devnull, "r"), stdout=PIPE, stderr=PIPE) |
|
0 commit comments