-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAcrostic.py
More file actions
54 lines (42 loc) · 1.17 KB
/
Acrostic.py
File metadata and controls
54 lines (42 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import nltk
import markovify
import json
import syllables
import re
import spacy
def poem():
nlp = spacy.load("en")
text = ""
with open("Turing.txt", "r", encoding="utf-8") as f:
read = f.read().splitlines()
for row in read:
text+=row
text_model = markovify.Text(text)
a, c, d, f = 'x', 'x', 'x', 'x'
while(a != "B"):
one = text_model.make_short_sentence(50)
if one != None:
a = list(one)[0]
while(c[0] != "I"):
two = text_model.make_short_sentence(50)
if two != None:
c = list(two)[0]
while(d!= "T"):
three = text_model.make_short_sentence(50)
if three != None:
d = list(three)[0]
while(f != "S"):
four = text_model.make_short_sentence(50)
if four !=None:
f = list(four)[0]
one = list(one)
one.insert(2, " ")
one = "".join(one)
try:
print(one.replace(".", "").replace("?","").replace("!", ""))
print(two.replace(".", "").replace("?","").replace("!", ""))
print(three.replace(".", "").replace("?","").replace("!", ""))
print(four.replace(".", "").replace("?","").replace("!", ""))
print(five.replace(".", "").replace("?","").replace("!", ""))
except:
pass