I think you just have some indentation problems. I also added u''
to the connectives to specify unicode since I am using python 2.7.
You need to maybe add a carriage return with the .
if you want it to split an existing line into two lines...
Here is a start (but not final):
import codecs
connectives=[u'കാരണം',u'അതുകൊണ്ട് ',u'പക്ഷേ',u'അതിനാല്',u'എങ്കിലും',u'എന്നാലും',u'എങ്കില്',u'എങ്കില്പോലും',
u'എന്നതുകൊണ്ട് ',u'എന്ന']
fr = codecs.open('i.txt', encoding='utf-8')
# fw = codecs.open('outputfile.txt', 'w')
for line in fr:
line_data=line.split()
for x, e in list(enumerate(line_data)):
if e in connectives:
line_data[x]='.\n'
print " ".join(line_data).lstrip()
Generates this output (extra space because the split comes in the middle of a line).
പ്രധാനമന്ത്രി മന്മോഹന്സിംഗ് നാട്ടില് എത്തി .
അദ്ദേഹം മലയാളി അല്ല .
അദ്ദേഹത്തെ പറ്റി പറയാന് വാക്കുകല്ളില്ല .