Nos_MT-OpenNMT-es-gl / translate.py
imdbo's picture
update model to ct2
436467d
raw
history blame
404 Bytes
import ctranslate2
import sys
model = sys.argv[1]
file_name = sys.argv[2]
file = open(file_name, 'r')
translator = ctranslate2.Translator(model, device="cuda")
for line in file:
line = line.strip()
r = translator.translate_batch(
[line.split()], replace_unknowns=True, beam_size=5, batch_type='examples'
)
results =' '.join(r[0].hypotheses[0])
print(results)