You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
855 B
Python

import nltk
with open('speech.txt','r') as result:
r = result.read()
r = r.replace('<span class="interim"></span>','').replace('\n','. ')
l=nltk.word_tokenize(r)
pos = nltk.pos_tag(l)
html = '''
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="pagedjs_files/interface.css">
<script src="pagedjs_files/paged.polyfill.js"></script>
<link rel="stylesheet" href="styles/1.css">
<meta charset="utf-8"/>
<title>Booklet</title>
</head>
<body>
'''
for x in pos:
if x[0] == '.':
html += "<span class='dot'>.</span><br> \n"
else:
html += "<span class='"+x[1]+"'> "+x[0]+"</span>\n"
html += '''</body>
</html>'''
html = html.replace(' .','.').replace(" '", "'")
with open('index.html','w') as index:
index.write(html)