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.

35 lines
819 B
Python

3 years ago
import nltk
nltk.download('punkt')
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> "
else:
html += "<span class='"+x[1]+"'>"+x[0]+"<span> "
html = '''</body>
</html>'''
with open('index.html','w') as index:
index.write(html)