Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -157,8 +157,14 @@ MAJOR_COUNTRIES = list(COUNTRY_LOCATIONS.keys())
|
|
157 |
|
158 |
def translate_query(query, country):
|
159 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
if country in COUNTRY_LANGUAGES:
|
161 |
-
# South Korea
|
162 |
if country == "South Korea":
|
163 |
print(f"ํ๊ตญ ์ ํ - ์๋ณธ ์ฌ์ฉ: {query}")
|
164 |
return query
|
@@ -190,17 +196,13 @@ def translate_query(query, country):
|
|
190 |
return query
|
191 |
|
192 |
def is_english(text):
|
193 |
-
|
|
|
|
|
194 |
|
195 |
def is_korean(text):
|
196 |
return any('\uAC00' <= char <= '\uD7A3' for char in text)
|
197 |
|
198 |
-
# ์ฌ์ฉ ์์:
|
199 |
-
# query = "์ผ์ฑ์ ์"
|
200 |
-
# country = "Japan"
|
201 |
-
# translated = translate_query(query, country)
|
202 |
-
# print(f"์
๋ ฅ: {query}, ๊ตญ๊ฐ: {country}, ๋ฒ์ญ: {translated}")
|
203 |
-
|
204 |
def is_english(text):
|
205 |
return all(ord(char) < 128 for char in text.replace(' ', ''))
|
206 |
|
|
|
157 |
|
158 |
def translate_query(query, country):
|
159 |
try:
|
160 |
+
# ์์ด ์
๋ ฅ ํ์ธ
|
161 |
+
if is_english(query):
|
162 |
+
print(f"์์ด ๊ฒ์์ด ๊ฐ์ง - ์๋ณธ ์ฌ์ฉ: {query}")
|
163 |
+
return query
|
164 |
+
|
165 |
+
# ์ ํ๋ ๊ตญ๊ฐ๊ฐ ๋ฒ์ญ ์ง์ ๊ตญ๊ฐ์ธ ๊ฒฝ์ฐ
|
166 |
if country in COUNTRY_LANGUAGES:
|
167 |
+
# South Korea ์ ํ์ ํ๊ธ ์
๋ ฅ์ ๊ทธ๋๋ก ์ฌ์ฉ
|
168 |
if country == "South Korea":
|
169 |
print(f"ํ๊ตญ ์ ํ - ์๋ณธ ์ฌ์ฉ: {query}")
|
170 |
return query
|
|
|
196 |
return query
|
197 |
|
198 |
def is_english(text):
|
199 |
+
# ์์ด์ ์ผ๋ฐ์ ์ธ ๊ธฐํธ๋ง ํฌํจ๋ ๊ฒฝ์ฐ True ๋ฐํ
|
200 |
+
return all(ord(char) < 128 for char in text.replace(' ', '').replace('-', '').replace('_', ''))
|
201 |
+
|
202 |
|
203 |
def is_korean(text):
|
204 |
return any('\uAC00' <= char <= '\uD7A3' for char in text)
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
def is_english(text):
|
207 |
return all(ord(char) < 128 for char in text.replace(' ', ''))
|
208 |
|