This repository has been archived by the owner on Jul 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.py
88 lines (69 loc) · 2.23 KB
/
generate.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from ctypes import sizeof
from itertools import zip_longest
import random
random.seed(1)
n = '\n'
phadjective = "<adj>"
phnoun = "<noun>"
phverb = "<verb>"
phadverb = "<adverb>"
phpreposition = "<prep>"
phinterjection = "<interj>"
phinteger = "<integer>"
def gettext(filename):
try:
f = open(filename, 'r')
except:
f = open(filename, 'w').close()
f = open(filename, 'r')
output = f.read()
f.close()
return output
def converttxttoarray(text):
text = text.split(n)
return text
def digestgrammar(t):
output = ""
for i in range(10):
i = t
i = i.replace(phadjective, random.choice(adjectives))
i = i.replace(phnoun, random.choice(nouns))
i = i.replace(phverb, random.choice(verbs))
i = i.replace(phadverb, random.choice(adverbs))
i = i.replace(phpreposition, random.choice(prepositions))
i = i.replace(phinterjection, random.choice(interjections))
i = i.replace(phinteger, random.choice(integers))
output += i + n
return output
#set the text that we will be adding onto
text = gettext('origin.txt')
#get adjectives from adjectives.txt
adjectives = converttxttoarray(gettext('adjectives.txt'))
#get nouns from nouns.txt
nouns = converttxttoarray(gettext('nouns.txt'))
#get verbs from verbs.txt
verbs = converttxttoarray(gettext('verbs.txt'))
#get adverbs from adverbs.txt
adverbs = converttxttoarray(gettext('adverbs.txt'))
#get prepositions from prepositions.txt
prepositions = converttxttoarray(gettext('prepositions.txt'))
#get conjunctions from conjunctions.txt
conjunctions = converttxttoarray(gettext('conjunctions.txt'))
#get interjections from interjections.txt
interjections = converttxttoarray(gettext('interjections.txt'))
#get integers from integers.txt
integers = converttxttoarray(gettext('integers.txt'))
#get the setups from setups.txt
setups = converttxttoarray(gettext('setups.txt'))
def digestsetup(t):
output = ""
output = digestgrammar(t)
return output
#open up splashes.txt in write mode so we can
#continue our trolling
splashes = open('splashes.txt', 'w')
for setup in setups:
text = text + digestsetup(setup)
#write the text to the file and close it
splashes.write(text)
splashes.close()