This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glibberisher.py
54 lines (40 loc) · 1.26 KB
/
glibberisher.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
from random import choice, randint, random
import gibberish
from gibberish import *
gib = Gibberish()
def pick_letter():
rare_letters = 'qwxz'
vovels = 'aeoiuy'
consonants = 'bcdfghjklmnprstv'
pick = random()
if pick > 0.9:
return choice(rare_letters)
elif pick > 0.35:
return choice(vovels)
else:
return choice(consonants)
def gen_word():
word_len = randint(2, 9)
return ''.join(pick_letter() for _ in range(word_len))
def gen_sentence(num_words=7):
words = (gen_word() for _ in range(num_words))
return ' '.join(words).capitalize() + '. '
def gen_sentence2(num_words=7):
words = (gib.generate_word() for _ in range(num_words))
return ' '.join(words).capitalize() + '. '
def gen_text(num_sentences=10, the=False):
sizes = (randint(3, 12) for _ in range(num_sentences))
sentences = ''
for size in sizes:
sentences += f'{gen_sentence(size)}'
if the:
sentences += '\n'
return ''.join(sentences)
def gen_text2(num_sentences=10, the=False):
sizes = (randint(3, 12) for _ in range(num_sentences))
sentences = ''
for size in sizes:
sentences += f'{gen_sentence2(size)}'
if the:
sentences += '\n'
return ''.join(sentences)