def word_Rep(text,Dic_Word):
rc = re.compile('|'.join(map(re.escape, Dic_Word)))
def translate(match):
return Dic_Word[match.group()]
return rc.sub(translate, text)
Dic_Word= {
#A Words
'a':'ein',
'an':'eine',
'able':'KOmmen',
'about':'gegen',
'above':'Uber',
'absence':'Abwesenheit',
'absent':'abwesend',
'accent':'Betonung',
'accept':'akzeptieren',
'according':'nach',
'acquainted':'kennen',
'across':'uber'
}
Text_Trans= raw_input("[*]ENTER THE TEXT TO TRANSLATE:")
Trans=word_Rep(Text_Trans,Dic_Word)
print Trans
please refer the above code. What happens here is that ,if a user gives the input in the command prompt as Input: a an able aunt. The output should be ein eine kommen Tante. But what I am getting is ein einn einble einunt and so on , the 'a' is getting replaced where ever the 'a' is occuring, Any help ?