39 lines
937 B
Python
39 lines
937 B
Python
import json
|
|
import maths
|
|
import random
|
|
|
|
def words(config):
|
|
dictation = []
|
|
words_list = []
|
|
with open(f'languages/{config['language']}.json', 'r') as file:
|
|
dump = json.load(file)
|
|
words_list = dump['words']
|
|
|
|
for i in range(0,config['mode_modifier']):
|
|
x = maths.biased_random(len(words_list)-1)
|
|
dictation.append(words_list[x])
|
|
return dictation
|
|
|
|
def time(config):
|
|
dictation = []
|
|
words_list = []
|
|
with open(f'languages/{config['language']}.json', 'r') as file:
|
|
dump = json.load(file)
|
|
words_list = dump['words']
|
|
|
|
# TODO: Really, these should be generated on demand
|
|
for i in range(0,config['mode_modifier']*3):
|
|
x = maths.biased_random(len(words_list)-1)
|
|
dictation.append(words_list[x])
|
|
return dictation
|
|
|
|
def quote(config):
|
|
dictation = []
|
|
with open(f'quotes/{config['language']}.json', 'r') as file:
|
|
quotes = json.load(file)
|
|
print(quotes)
|
|
x = random.randint(0,len(quotes)-1)
|
|
print(quotes[x])
|
|
|
|
return dictation
|