-
Notifications
You must be signed in to change notification settings - Fork 0
/
lorem.py
35 lines (33 loc) · 1.91 KB
/
lorem.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
from random import randint
def lorem_generator(paragraphs_number):
"""This function aims to build a lorem generator for the DinofauroFexBot"""
CONECTIVES_LIST = ['do','vah','ki','in','pro','stra','gma','tri','tong','ne','et','me','tos','bahs','noni','male'] #Aleatórios
WORDS_LIST = ['avada','kedavra','lumus','maximus','accio','aguamenti','alarte','ascendare','alohomora','aparecium','apparate',
'aqua','eructo','ascendio','avis','avifors','arresto','momentum','arania','exumai','baubillious','bombarda','maxima','brackium','emendo',
'calvario','cantis','carpe','retractum','cave','inimicum','cistem','aperio','colloportus','colloshoo','colovaria','cofundo','ventus','duo','vara',
'verto','verdimillious']
#Source: http://harrypotter.wikia.com/wiki/List_of_spells (Inseridas manualmente)
#rr stands for repeat rule (after x events will ocur, where x is the number designated for each variable)
numberof_paragraphs = range(paragraphs_number)
conectives_rr = 3 #Could variate randomly. It will be analised later
lorem = ""
len_conectives = len(CONECTIVES_LIST)
len_words = len(WORDS_LIST)
for i in numberof_paragraphs:
conective_flag = 0
paragraphslen_rr = randint(80,150)
for j in range(paragraphslen_rr):
comma_rr = randint(4,15)
if conective_flag == 3:
lorem += CONECTIVES_LIST[randint(0,len_conectives-1)] + " "
conective_flag = 0
if j==0 or (lorem[-1]=='n' and lorem[-2]=="\\"):
lorem += WORDS_LIST[randint(0,len_words-1)].title() + " "
else:
lorem += WORDS_LIST[randint(0,len_words-1)] + " "
conective_flag += 1
lorem += "\n\n"
return lorem
#teste
if __name__=='__main__':
print(lorem_generator(3))