-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoetry.py
More file actions
184 lines (149 loc) · 6.19 KB
/
Copy pathpoetry.py
File metadata and controls
184 lines (149 loc) · 6.19 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 24 19:40:42 2025
@author: sheng
@name: Generates random poetry
@description:
Generates words that make some sense and images that go with it
"""
import os, sys
import pickle
from datetime import datetime
import random
from pathlib import Path
from PIL import Image
import matplotlib.pyplot as plt
from wonderwords import RandomWord, RandomSentence
if __name__ == '__main__':
print('Please use -load in command line argument to load existing!')
file_path = 'words.pkl'
if '-load' in sys.argv:
with open(file_path, 'rb') as file:
words = pickle.load(file)
print('Words loaded: ', words)
else:
w = RandomWord()
word_start = w.word()
adjective1 = w.word(include_categories=["adjective"])
noun1 = w.word(include_categories=["noun"])
verb1 = w.word(include_categories=["verb"])
loc_start = w.filter(word_min_length=4, starts_with="loc")
others = [word_start] + loc_start
# custom types
# TYPE 1
humans = ["Shen", "him", "her", "the one absorbed"]
sexuals = ["kiss", "fondle", "slap", "grasp", "penetrate", "fuck", "suck", "grope", "massage", "make love with"]
fruits = ["apple", "orange", "banana", "strawberry"]
generator = RandomWord(fruit=fruits, sexual=sexuals, human=humans)
# TYPE 2
bodyparts = ['body',
'breast',
'butt',
'eyes',
'face',
'feet',
'hair',
'legs',
'pussy']
models = ['Allie Haze',
'Emma Kuziara',
'Kylie Page',
'Leanna Lovings',
'Sapphire Blue',]
actions= ['eyeballing',
'imagining in bed with',
'pleasing oneself with thoughts of',
'starstruck over',
'watching',
'drooling over']
generator_x = RandomWord(bodypart=bodyparts, model=models, action=actions)
# TYPE 3
times = ['eternal',
'infinite',
'long'
'short',
'temporal',
'temporary',]
generator_time = RandomWord(time=times)
# random sentences
s = RandomSentence()
sentences = []
sentences.append(s.bare_bone_sentence())
sentences.append(s.simple_sentence())
sentences.append(s.sentence())
# saved up generator for image display as well
bodypart = generator_x.word(include_categories=['bodypart'])
model = generator_x.word(include_categories=['model'])
line000 = 'The lines above are mechanically created with uncuration except in adjective, verb and noun formation'
line001 = 'What follows is more deliberate.'
line01 = 'A ' + generator.word(include_categories=['human']) + ' loves to ' + generator.word(include_categories=['sexual']) + ' ' + generator.word(include_categories=['fruit'])
line02 = f"Yet, to a {generator.word(include_categories=['human'])}, nothing feels quite as good as spending hours"
line03 = 'staring at a screen and ' + generator_x.word(include_categories=['action']) + ' the ' + bodypart + ' of ' + model
line04 = 'The euphoria may be ' + generator_time.word() + ' and the shame may be ' + generator_time.word()
line05 = 'The cycle repeats...'
sentences.append(line000)
sentences.append(line001)
sentences.append(line01)
sentences.append(line02)
sentences.append(line03)
sentences.append(line04)
sentences.append(line05)
words = {
'adjectives': [adjective1],
'nouns': [noun1],
'verbs': [verb1],
'others': others,
'sentences': sentences,
'bodypart': bodypart,
'model': model,
}
#%%
result = ' '.join([words['adjectives'][0], words['nouns'][0], words['verbs'][0]])
result2 = ' '.join([words['others'][1], words['others'][2]])
lines_to_save = [
words['others'][0],
'----------------'+'\n',
result.capitalize()+'\n',
result2.capitalize()+'\n',
]
lines_to_save2 = []
for sentence in words['sentences']:
lines_to_save2.append(sentence+'\n')
lines_to_save.extend(lines_to_save2)
for line in lines_to_save:
print(line)
#%% Image opener
# img = Image.open('data_img/emmak/emma-k-13.jpg') # if not using random
# random image from the folder
if model in ['Allie Haze']:
image_dir = Path('data_img/AllieHaze_model')
elif model in ['Emma Kuziara']:
image_dir = Path("data_img/EmmaKuziara_model")
elif model in ['Kylie Page']:
image_dir = Path("data_img/KyliePage_model")
elif model in ['Leanna Lovings']:
image_dir = Path("data_img/LeannaLovings_model")
elif model in ['Sapphire Blue']:
image_dir = Path("data_img/SapphireBlue_model")
images = list(image_dir.glob("*.jpg")) + list(image_dir.glob("*.png"))
if not images:
raise ValueError("No images found in folder")
img_path = random.choice(images)
# open up the image
img = Image.open(img_path)
plt.imshow(img)
plt.axis("off") # hide axes
plt.tight_layout(pad=0)
plt.show()
#%% Write the poetry to a text file and save the words to a word database
os.makedirs('poetry', exist_ok=True)
current_datetime = datetime.now()
filename = current_datetime.strftime("%Y-%m-%d_%H-%M-%S.%f") + ".txt"
filepath = 'poetry/' + filename
with open(filepath, 'w') as f:
f.writelines(lines_to_save)
if '-verbose' in sys.argv:
print('Word database saved: ', words)
with open(file_path, 'wb') as file:
pickle.dump(words, file)
print(f'Words have been saved to {file_path}')