Script to create flashcard sets

markv

秀才
Hello everyone,

I wanted to make a few sets of flashcards but it took a lot of effort to do it on my phone. Therefore I made a Python (2.7) script to find cards given a word. I don't know if this already exists (didn't see it yet), so just ignore this part if it does. It works like this:

python find_flash_cards.py zero one two three four five six seven eight nine ten hundred thousand

零 ling2 [líng] zero; 零件 língjiàn spare part; 零钱 spare change [līng] 孤零零 gūlīnglīng solitary, all alone; 丁零零 dīnglīnglīng tinkle, jingle
魏 Wei4 [Wèi] one of the Three Kingdoms, name of several dynasties, <family name>
二 er4 [èr] two; 二月 èryuè February
三 san1 [sān] three; 第三世界 dì-sān shìjiè 3rd World; 三月 sānyuè March
四 si4 [sì] four; 四周 sìzhōu all around; 四月 sìyuè April
五 wu3 [wǔ] five; 五月 wǔyuè May
六 liu4 [liù] six; 六月 liùyuè June {Compare with 兴 xìng prosper}
七 qi1 [qī] seven; 七月 qīyuè July
八 ba1 [bā] eight; 八月 Bāyuè August
九 jiu3 [jiǔ] nine; 九月 jiǔyuè September
十 shi2 [shí] ten; 十三 shísān thirteen; 五十 wǔshí fifty; 十月 shíyuè October
百 bai3 [bǎi] hundred [bò] 抄总 chāobòzǒng express/cover everything {Compare with 白 bái white}
千 qian1 [qiān] thousand {Compare with 干 gān stem and 于 yú at}

As you can see, it got 'one' wrong but except for that does a pretty good job. If I want to find 'one', I can do one of those (depending if I know how to say 'one'):

python find_flash_cards.py -ALL one
python find_flash_cards.py -PINYIN -ALL yi
python find_flash_cards.py -PINYIN -ALL yi1

The first returns all flashcards with a free 'one' in the definition (35), the second returns all 'yi' (38) and the third returns just 5 cards, from which I can easily select the correct one (hehe, 'one').

一 yi1 [yī] one, a little; 第一 dì-yī first, primary; 看一看 kànyīkàn have a (quick) look at [yí] (used before tone #4); 一个人 yí gè rén one person; 一定 yídìng certain; 一样 yíyàng same; 一月yíyuè January [yì] (used before tones #2 and #3); 一点儿 yìdiǎnr a little; 一些 yìxiē some {Compare with 幺 yāo, which also means "one"}

I don't know if this is useful for anyone, so I'll post it here just in case. You need Python 2.7, change the extension to .py as in the demo. You also need 'all.txt' which contains all flashcards, hopefully I'm allowed to post mine, otherwise export your own.

EDIT: updated version
 

Attachments

  • all.txt
    379.4 KB · Views: 4,177
  • find_flash_cards.py.txt
    2.3 KB · Views: 554
Last edited:
Top