You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 23, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 23, 2024. It is now read-only.
[google cloud translate] as a result of translation, the second sentence disappeared #9
Python version and virtual environment information: python --version
python 3.7
google-cloud- version: pip show google-<service> or pip freeze
google-cloud-translate==2.0.1
Steps to reproduce
Translate the two sentences written in Korean without spaces after the special symbols (.,! ...) using the google cloud translate API.
Code example
# examplefromgoogle.cloudimporttranslate_v2astranslatetranslate_client=translate.Client()
# case 1comments='야 너 왜 자꾸 문제 생겨.자꾸 이러면 못써'myTrans1=translate_client.translate(comments, target_language='en')
print('case 1 : ',myTrans1['translatedText'])
# case 2comments='야 너 왜 자꾸 문제 생겨. 자꾸 이러면 못써'myTrans2=translate_client.translate(comments, target_language='en')
print('case 2 : ', myTrans2['translatedText'])
Result
case 1 : Hey, why do you keep having problems?
case 2 : Hey, why do you keep having trouble? If I keep doing this, I can't use it
This is 100% reproducible. It needs credential key (GOOGLE_APPLICATION_CREDENTIALS) because I use paid service (Google Cloud Translate V2)
The difference in input data is just whether there is a space after the period or not. However, as a result of translation, in case 2, the second sentence disappeared without being translated.
fromgoogle.cloudimporttranslateclient=translate.TranslationServiceClient()
parent=client.location_path('PROJECT_ID', "global")
text_no_space='야 너 왜 자꾸 문제 생겨.자꾸 이러면 못써'text_with_space='야 너 왜 자꾸 문제 생겨. 자꾸 이러면 못써'fortextin [text_no_space, text_with_space]:
response=client.translate_text(
parent=parent,
contents=[text],
mime_type="text/plain",
source_language_code="ko",
target_language_code="en",
)
# Display the translation for each input text providedfortranslationinresponse.translations:
print(u"Translated text: {}".format(translation.translated_text))
From poking around with different inputs this doesn't seem to always happen. '너 왜 자꾸 문제 생겨.이러면 못써 -> Why do you keep having problems? 너 왜 자꾸 문제 생겨.너 이러면 못써 -> Why do you keep having trouble, you can't use this
If feasible, you could insert spaces around the punctuation as a work-around.
@czahedi Where is the correct place to provide feedback on translation quality?
@InspiringPeople I encourage you to file an issue above and get your feedback directly to the product team, and refer to Bu Sun's workaround in the meantime. Thanks!
Activity
busunkim96 commentedon Apr 3, 2020
Interesting. This looks like something coming from the backend. I tried the v2 REST API directly, the v3 client, and translate.google.com
REST API:
v3 client
From poking around with different inputs this doesn't seem to always happen.
'너 왜 자꾸 문제 생겨.이러면 못써->Why do you keep having problems?너 왜 자꾸 문제 생겨.너 이러면 못써->Why do you keep having trouble, you can't use thisIf feasible, you could insert spaces around the punctuation as a work-around.
@czahedi Where is the correct place to provide feedback on translation quality?
czahedi commentedon Apr 3, 2020
Howdy! Just checked with the translation team and they have a public feedback / issue tracking forum here: https://issuetracker.google.com/issues?q=componentid:187144
czahedi commentedon Apr 3, 2020
@InspiringPeople I encourage you to file an issue above and get your feedback directly to the product team, and refer to Bu Sun's workaround in the meantime. Thanks!