import nltk nltk.download('punkt') with open('speech.txt','r') as result: r = result.read() r = r.replace('','').replace('\n','. ') l=nltk.word_tokenize(r) pos = nltk.pos_tag(l) html = ''' Booklet ''' for x in pos: if x[0] == '.': html += ".
" else: html += ""+x[0]+" " html = ''' ''' with open('index.html','w') as index: index.write(html)