I have a unicode encoded malayalam text file say a.txt. i am storing each word from that text file in to a list. so the list contains each word in the text.
example
text="അവള് പൊട്ടിക്കരഞ്ഞുകൊണ്ട് നൈല് നദീതീരം മുഴുവന് തന്റെ
കാമുകന്റെ ശരീരഭാഗങ്ങള്ക്കായി അലഞ്ഞുനടന്നു. ഒരുപക്ഷെ, മറെറാരു
പുരാണ-ഐതിഹ്യ കാവ്യങ്ങളിലും ഇത്ര ഹൃദയസ്പര്ശിയായ ഒരു തിരച്ചിലിന്റെ
കഥ വിവരിക്കപ്പെട്ടിട്ടുണ്ടാവില്ല."
but the sentence boundaries are also attached to the last word in the sentence. like [അലഞ്ഞുനടന്നു.]
i want to make it separate like [അലഞ്ഞുനടന്നു] [.]
[വിവരിക്കപ്പെട്ടിട്ടുണ്ടാവില്ല] [.]
I am doing like this
with codecs.open(r"C:\Users\cusat\Documents\Python Scripts\test document.txt",encoding="utf-8") as fpnr:
text=fpnr.read()
text_of_sentences=segmentize(text)
fpnr.close()
for sentence in text_of_sentences:
if len(sentence) > 1:
sentences.append(worder(sentence))
#print sentences
for sentence in sentences:
#print sentence
for word in sentence:
#print word
trimdwrds=trim(word)
wordses.append(trimdwrds)
for word in wordses:
if len(word) >= 1:
re.sub(r'([\u0900-\u097F]+)(\.)(\s*)', r'\1 \2', word)