Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Inconsistent translation between Cloud Translate (python API) and web version (translate.google.com)

Hello

I noticed that there are some inconsistencies between the translations done via the Cloud Translate API and in the web interface on translate.google.com, specifically in how they handle special characters and sequences

E.g.
with input of:

  Which PyTorch 1.8 command(s) produce $10\times 5$ Gaussian matrix with each entry i.i.d.
API to French:
 Quelle(s) commande(s) PyTorch 1.8 produisent une matrice gaussienne de 10 $ imes 5$ avec chaque entrée i.i.d.
Web to French:
  Quelle(s) commande(s) PyTorch 1.8 produisent une matrice gaussienne $10\times 5$ avec chaque entrée i.i.d.

Please note how \t in the formula disappeared in the API response, yet it is present in the web version's translation

Why does it happen? Is there any way to get the exact same translation via API as in the web UI?
Thank you.

0 1 247
1 REPLY 1

Hi @aizdorovets

Welcome and thank you for reaching out to our community.

I get that you are having difficulty understanding the difference between the API and Web version of Cloud Translate. A quick explanation is, both are designed differently hence there is no guaranteed way to get the exact same translation. The Web UI is much simpler in comparison to the API which is more robust and customizable.

The characters in question "\t" will be considered as a whitespace key or code in the API, it is usually removed during translation, unless coded otherwise, to improve accuracy especially when translating code snippets. It is a code that signifies the horizontal tab function, hence you'll notice that the space between the "$" sign and the "imes" word.

I hope this helps shed some light.