<jupyter_start><jupyter_text>Load word + translation pairs<jupyter_code>translation_pairs = parse_markdown_list('wordslearned.md')<jupyter_output><empty_output><jupyter_text>Shuffle pairs<jupyter_code>random.seed(time.time())
# Or use fixed seeds
# random.seed(42)
pair_idx = 0
n_pairs = len(translation_pairs)

def check_translation(b):
    global pair_idx
    word = translation_pairs[pair_idx][0]
    possible_translations = translation_pairs[pair_idx][1]
    if translation_box.value.strip() in possible_translations:
        print('You receive a robust lavender herring')
    else:
        print('You receive a sickly teal herring')
    print(f'  Possible translations for {word}: {". ".join(possible_translations)}')
    pair_idx = (pair_idx + 1) % n_pairs
    translation_box.value = ''
    swedish.value = f'<center>{translation_pairs[pair_idx][0]}</center>'
    pass

grid = ipw.GridspecLayout(4, 1)
swedish = ipw.HTML(
    value=f'<center>{translation_pairs[pair_idx][0]}</center>')
translation_box = ipw.Text(
    value='',
    placeholder='Enter translation')
check_button = ipw.Button(
    description='Check',
    layout=ipw.Layout(width='50%'))
check_button.on_click(check_translation)

grid = ipw.GridspecLayout(3, 1)
grid[0, 0] = swedish
grid[1, 0] = translation_box
grid[2, 0] = check_button

grid<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1308550185873606, 'fraction_numerical': 0.01486988847583643, 'mean_word_length': 5.533980582524272, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '281371', 'license': 'MIT', 'n_tokens_mistral': 482, 'n_tokens_neox': 473, 'n_words': 83, 'path': 'svenska/flashcards.ipynb', 'repo_name': 'heyitsguay/heyitsguay.github.io', 'size': '1345'}