Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import enchant
- row_data = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm']
- row_choices_used = []
- row_choice = random.choice(range(0, len(row_data)))
- data = ''
- data_list = []
- d = enchant.Dict('en_US')
- count = 0
- possibility_count = 0
- while possibility_count < 3780:
- while count < len(row_data):
- while row_choice in row_choices_used:
- row_choice = random.choice(range(0, len(row_data)))
- row_choices_used.append(row_choice)
- the_choice = random.choice(row_data[row_choice])
- data += the_choice
- count += 1
- if data not in data_list:
- data_list.append(data)
- possibility_count += 1
- row_choices_used = []
- data = ''
- count = 0
- f = open("data.txt", "w")
- useless_words = 0 # Just for reference
- useful_words = 0 # Also for reference
- for word in data_list:
- if d.check(word) == True:
- f.write(word + '\n')
- useful_words += 1
- else:
- useless_words += 1
- f.close()
- print("Number of English words :", str(useful_words))
- print("Number of random words :", str(useless_words))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement