-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgibberish.py
More file actions
20 lines (15 loc) · 741 Bytes
/
gibberish.py
File metadata and controls
20 lines (15 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#A gibberish text generator which tries to follow the letter frequencies to sometimes(like rarely) produce meaningful words.
from random import random
let=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ']
frq=[855,160,316,387,1209,218,209,496,733,22,81,421,253,717,747,207,10,633,673,894,268,106,183,19,172,11,2127]
#list for choosing letters according to their frequency in english language text.
wtlet = []
for i in range(len(let)):
wtlet += [let[i] for j in range(frq[i])]
#Len of gibberish text to be produced.
n = int(input("Enter the length of text:\n"))
text=""
for i in range(n):
text+=wtlet[min(len(wtlet)-1,int(random()*len(wtlet)))]
#Result
print(text)