Skip to content
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

Result mismatch Google Translate #80

Open
joeperpetua opened this issue Mar 27, 2023 · 5 comments
Open

Result mismatch Google Translate #80

joeperpetua opened this issue Mar 27, 2023 · 5 comments

Comments

@joeperpetua
Copy link

Hi guys, hope you are doing well.
I know that you are pretty busy working on v3 and may are already aware of this already, but just in case I open this issue.

When using the GoogleTranslate service, the translation is different from what we get in the website/app:

  • Source: fr (auto)
  • Destination: en
  • Text: Sincèrement navré de ne pas avoir répondu à vos messages plus rapidement, lorsque le dossier est transmis aux développeurs, nous n'avons temporairement plus de visibilité dessus.

[1] Google translate result:
Sincerely sorry for not having replied to your messages more quickly, when the file is transmitted to the developers, we temporarily no longer have visibility on it.

[2] translatepy result:
Honestly sorry not to have answered your messages faster, when the file is transmitted to the developers, we do not temporarily have more visibility on it.

Any ideas of what/why could be this caused? I actually tried changing the session header as per #79 but it did not have any effect on the translation result.

[1]
image

[2]

Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import translatepy
>>> translatepy.Translator().translate("Sincèrement navré de ne pas avoir répondu à vos messages plus rapidement, lorsque le dossier est transmis aux développeurs, nous n'avons temporairement plus de visibilité dessus.", "en")
TranslationResult(service=Google, source=Sincèrement navré de ne pas avoir répondu à vos messages plus rapidement, lorsque le dossier est transmis aux développeurs, nous n'avons temporairement plus de visibilité dessus., source_language=fra, destination_language=eng, result=Honestly sorry not to have answered your messages faster, when the file is transmitted to the developers, we do not temporarily have more visibility on it.)
>>>
@ZhymabekRoman
Copy link
Contributor

ZhymabekRoman commented Mar 27, 2023

Related issue: #22 (comment)
Try to use GoogleTranslateV2 class as workaround: #22 (comment)

@joeperpetua
Copy link
Author

Thanks, that works well!
So I understand that the GoogleTranslate service defaults to GoogleTranslateV1, right? I assumed it used the V2 by default 😅

@Animenosekai
Copy link
Owner

Thanks, that works well!
So I understand that the GoogleTranslate service defaults to GoogleTranslateV1, right? I assumed it used the V2 by default 😅

Yup for now GoogleTranslateV1 is tried first

self.services = [google_v1, google_v2]
def _translate(self: C, text: str, dest_lang: typing.Any, source_lang: typing.Any) -> models.TranslationResult[C]:
for service in self.services:
try:
return service._translate(text, dest_lang, source_lang)
except Exception:
continue
raise ValueError("No service has returned a valid result")

The reason is that V1 should be the one used on the website, but we can't generate the right tokens for now : #22 (comment)

@ghost
Copy link

ghost commented Jul 20, 2023

@Animenosekai so v2 better than v1?

@Animenosekai
Copy link
Owner

@Animenosekai so v2 better than v1?

Well without reverse engineering the token generation, yes (maybe?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants