[英]How to check if the translation is checked by community using googletrans module in Python?
I am trying to translate some words using googletrans
Python module.我正在尝试使用
googletrans
Python 模块翻译一些单词。 It translates the words, but I need to check if the translation checked by Google Translate Community.它翻译了这些单词,但我需要检查谷歌翻译社区是否检查了翻译。 How can I do it?
我该怎么做?
I've tried to use this code, but the confidence attribute value is always 1.0, though the first phrase is checked by community, and the second one is not:我尝试使用此代码,但信心属性值始终为 1.0,尽管第一个短语由社区检查,而第二个不是:
from googletrans import Translator
translator = Translator() # initialize the Translator
# translate two phrases from English to Ukrainian
translation1 = translator.translate("to be", "uk")
translation2 = translator.translate("I'm fond of programming", "uk")
# print the result and if it is already checked by community
print(translation1.text, translation1.extra_data["confidence"])
print(translation2.text, translation2.extra_data["confidence"])
# It prints:
# бути 1.0
# Я захоплююся програмуванням 1.0
I am not 100% sure, but it appears there is a flag in "translation" array in the extra data that represents the community checked status.我不是 100% 确定,但在额外数据中的“翻译”数组中似乎有一个标志,表示社区检查状态。
from googletrans import Translator
translator = Translator() # initialize the Translator
# translate two phrases from English to Ukrainian
translation1 = translator.translate("to be", "uk")
translation2 = translator.translate("I'm fond of programming", "uk")
# print the result and if it is already checked by community
print(translation1.text, translation1.extra_data["translation"][0][4])
print(translation2.text, translation2.extra_data["translation"][0][4])
# Output
# бути 1
# Я захоплююся програмуванням 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.