ഉപയോക്താവ്:Junaidpv/translator.py
ദൃശ്യരൂപം
import codecs
import wikipedia
site=wikipedia.getSite('ml','wiktionary')
wpage = wikipedia.Page(site,'User:Junaidpv/translation_table')
text = wpage.get(get_redirect=True)
ttable = eval(text)
#print repr(ttable)
ifileName=raw_input("Enter: input file name: ")
infile = codecs.open(ifileName, encoding='utf-8')
text = infile.read()
for e, m in ttable.iteritems():
text=text.replace(e,m)
ofileName = raw_input("Enter: output file name (if file exists, will be replaced: ")
ofile = codecs.open(ofileName,mode='w+', encoding='utf-8')
ofile.write(text)
ofile.flush()
ofile.close()