Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Traductor de Español a Simpl-Español
#!/usr/bin/python
# Uso:
# $ python simpl-es.py input.txt > output.txt
from sys import argv
ifile = argv[1]
f = open(ifile, 'r')
o = f.read()
f.close()
# salvar CH
o = o.replace('ch', 'xx')
o = o.replace('Ch', 'Xx')
# eliminar H
o = o.replace('h', '')
o = o.replace('Ha', 'A')
o = o.replace('He', 'E')
o = o.replace('Hi', 'I')
o = o.replace('Ho', 'O')
o = o.replace('Hu', 'U')
# restituir CH
o = o.replace('xx', 'ch')
o = o.replace('Xx', 'Ch')
# reemplazar V por B
o = o.replace('v', 'b')
o = o.replace('V', 'B')
# reemplazar G fuerte por J
o = o.replace('ge', 'je')
o = o.replace('gi', 'ji')
o = o.replace('Ge', 'Je')
o = o.replace('Gi', 'Ji')
# reemplazar G suave (gu por g sola)
o = o.replace('gue', 'ge')
o = o.replace('gui', 'gi')
o = o.replace('Gue', 'Ge')
o = o.replace('Gui', 'Gi')
# reemplazar Q y C fuerte por K
o = o.replace('qu', 'k')
o = o.replace('Qu', 'K')
o = o.replace('ca', 'ka')
o = o.replace('co', 'ko')
o = o.replace('cu', 'ku')
o = o.replace('Ca', 'Ka')
o = o.replace('Co', 'Ko')
o = o.replace('Cu', 'Ku')
# reemplazar Z y C suave por S
o = o.replace('sc', 's')
o = o.replace('z', 's')
o = o.replace('Z', 'S')
o = o.replace('ce', 'se')
o = o.replace('ci', 'si')
o = o.replace('Ce', 'Se')
o = o.replace('Ci', 'Si')
# reemplazar LL por Y
o = o.replace('ll', 'y')
o = o.replace('Ll', 'Y')
# reemplazar Ñ por NI
o = o.replace('ñ', 'ni')
o = o.replace('Ñ', 'Ni')
# reemplazar X por CS
o = o.replace('x', 'cs')
o = o.replace('X', 'cs')
print(o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment