mirror of
https://github.com/chubin/cheat.sh.git
synced 2024-11-28 03:42:07 +03:00
initial support of foreign human languages in queries
This commit is contained in:
parent
5ed0e75424
commit
5911ea030f
@ -19,6 +19,7 @@ import os
|
||||
import re
|
||||
import redis
|
||||
from fuzzywuzzy import process, fuzz
|
||||
from langdetect import detect
|
||||
|
||||
import beautifier
|
||||
from globals import MYDIR, PATH_TLDR_PAGES, PATH_CHEAT_PAGES, PATH_CHEAT_SHEETS, COLOR_STYLES
|
||||
@ -250,7 +251,14 @@ def _get_answer_for_question(topic):
|
||||
"""
|
||||
|
||||
topic = " ".join(topic.replace('+', ' ').strip().split())
|
||||
cmd = ["/home/igor/cheat.sh/bin/get-answer-for-question", topic]
|
||||
|
||||
lang = detect(topic)
|
||||
if lang != 'en':
|
||||
topic = ['--human-language', lang, topic]
|
||||
else:
|
||||
topic = [topic]
|
||||
|
||||
cmd = ["/home/igor/cheat.sh/bin/get-answer-for-question"] + topic
|
||||
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
|
||||
answer = proc.communicate()[0].decode('utf-8')
|
||||
return answer
|
||||
|
Loading…
Reference in New Issue
Block a user