translate_studio / utils.py
vietdata's picture
first update
8144c2e
raw
history blame contribute delete
663 Bytes
from thefuzz import fuzz
from deep_translator import GoogleTranslator
import time
def gg_score(original, translation, target="en"):
while True:
try:
back_original = GoogleTranslator(source='auto', target=target).translate(translation)
gg_translation = GoogleTranslator(source='auto', target=target).translate(original)
break
except:
time.sleep(1)
continue
return (fuzz.token_set_ratio(original, back_original) + fuzz.token_set_ratio(gg_translation, translation))/200
def miner_score(translation, grouth):
return fuzz.token_set_ratio(translation, grouth)/100