Skip to main content

Frank's Site

Wen

Table of Contents

Train Window

# Intro

In 2019, a train ride from Hangzhou to Guilin, China, I began writing a program to help learn Chinese characters. It should show a character, optionally, with or without Pinyin, and the user can input the translation. Then, a score is calculated.

# Original Code

This original Python version uses dictionary files with comma-separated components: the Chinese character, the Pinyin with tone numbers, and the definition separated by forward slashes (/). An example would be:

零, li2ng, 0/zero

The program then splits up each section, replaces the tone numbers with diacritics (i.e. “líng”), and compares user input to each instance of the definitions. Here’s how that works:

for line in open_file:
    working_list = list(line.split(', '))
    characters.append(working_list[0].strip())
    pinyin.append(working_list[1].strip())
    translation.append(working_list[2].strip())`

The original Python code is here.

# Web Code

The online, user-friendly version can be found here, and a live version is hosted here.

This version was a way for me to learn JavaScript over about a week. I slapped a stylesheet on it and hooked in the header from my Hugo site. It’s designed so once you start a lesson, you don’t have to take your hands off the keyboard. Click “Review” to study the expected input. (I should probably use a language model for this in the future.)

Wen Online

Chinese is notoriously hard to learn, and Wen has helped me learn in my own way. I’ll keep it public in case someone else finds it useful.