File size: 404 Bytes
436467d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)