File size: 472 Bytes
35c1cfd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

import sys
from num2words import num2words

file = sys.argv[1]
out_file = sys.argv[2]

with open(file) as f:
    lines = f.readlines()

with open(out_file, "w") as fw:
    for line in lines:
        key, content = line.strip().split(maxsplit=1)
        new_content = ""
        for ct in content.split():
            if ct.isdigit():
                ct = num2words(ct)
            new_content += ct + " "
        fw.write(key + " " + new_content + "\n")