-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Google doesn't give the correct translation #163
Comments
And also, Yandex can translate Japanese, but apparently you haven’t updated this in the code |
@bropines Sorry for long time.
# My judgment:
if translators's google result == google web result:
return True
# Your judgment:
if translators's google result == My idea result:
return True Of course, Maybe this: #35
import translators as ts
print(ts.translate_text(query_text='你好', translator='yandex'))
ts.server._yandex.language_map.update({'ja': ['ru']}) # add lang_pair you want
print(ts.translate_text(query_text='こんにちは', translator='yandex', from_language='ja', to_language='ru')) |
Imagine typing a sentence in real time in a web page translation window. How many times does the request result refresh behind it? If the input generated a large number of translation requests queue in a short time, if I were a developer, I would design a sliding window such as 24ms, I only handle the latest request in the sliding window, so as to basically meet the effect of real-time translation of the web page. |
That is, I make requests so quickly that the second part of the translation simply doesn’t load for me... Right? And essentially I can just make the wait a little longer when receiving a transfer. I wish I knew how.... |
I still remembered the problem. Here are my tests import translators as ts
# Define the original texts to translate
original_text_1 = "し 、 従いまひゅ 宮司 様……"
original_text_2 = "(kudze sara) し 、 従いまひゅ 宮司 様……"
# List of translators to test
translators_to_test = ['google', 'bing', 'alibaba', 'yandex']
# Print a sample Yandex translation to ensure functionality
try:
print(ts.translate_text(query_text='你好', translator='yandex'))
ts.server._yandex.language_map.update({'ja': ['ru']}) # Add language pair
print(ts.translate_text(query_text='こんにちは', translator='yandex', from_language='ja', to_language='ru'))
except Exception as e:
print(f"Failed to update or test Yandex language map: {e}")
# Function to perform translations and collect results
def translate_texts(original_texts, translators):
results = {}
for text in original_texts:
text_translations = {}
for translator in translators:
try:
translated_text = ts.translate_text(text, translator=translator, from_language='auto', to_language='ru')
except Exception as e:
translated_text = f"Ошибка при переводе: {str(e)}"
text_translations[translator] = translated_text
results[text] = text_translations
return results
# Translate the texts
results = translate_texts([original_text_1, original_text_2], translators_to_test)
# Format and print results
for original_text, translations in results.items():
print(f"Original text: {original_text}\n")
print("Translated text:")
for translator, translated_text in translations.items():
print(f"[{translator}] {translated_text}")
print("\n") Result: Original text: し 、 従いまひゅ 宮司 様……
Translated text:
[google] Итак, Маху Мияши ...
[bing] и Священник Храма......
[alibaba] Es, ま ま ま Дворец...
[yandex] я последую за тобой, господь махью.……
Original text: (kudze sara) し 、 従いまひゅ 宮司 様……
Translated text:
[google] (Кудзе Сара)
[bing] (кудзе сара) и г-н Миядзи......
[alibaba] (Kudze sara) «Дворец»...
[yandex] (кудзе Сара) тогда я буду повиноваться главному жрецу махью.…… |
Debug Tips
What happened?
For some reason, in response to the request, only one part of the text (brackets) is received, and the second is lost
APP Version
5.9.3 (default)
Python Version
3.10
Runtime Environment
Windows
Country/Region
Russia
Relevant log output
No response
Screenshots
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: