import nltk 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 += ''' ''' html = html.replace(' .','.').replace(" '", "'") with open('index.html','w') as index: index.write(html)