Skip to content

Instantly share code, notes, and snippets.

@hliang
Last active December 16, 2020 22:00
Show Gist options
  • Save hliang/bf7f3970d36349129c816f21b8b2485b to your computer and use it in GitHub Desktop.
Save hliang/bf7f3970d36349129c816f21b8b2485b to your computer and use it in GitHub Desktop.
anki cloze卡片生成器-中文生字-拼音-词语
filepath_zi = "grd3_b_cn_zi"
filepath_pinyin = "grd3_b_cn_pinyin"
filepath_ciyu = "grd3_b_cn_ciyu"
lst_zi = []
lst_pinyin = []
lst_ciyu = []
with open(filepath_zi) as f:
lst_zi = f.readlines()
lst_zi = [x.strip() for x in lst_zi]
with open(filepath_pinyin) as f:
lst_pinyin = f.readlines()
lst_pinyin = [x.strip() for x in lst_pinyin]
with open(filepath_ciyu) as f:
lst_ciyu = f.readlines()
lst_ciyu = [x.strip() for x in lst_ciyu]
for zi,pinyin,ciyu in zip(lst_zi, lst_pinyin, lst_ciyu):
cloze = "{{c1::%s::%s}}" % (zi, pinyin)
out_str = ciyu.replace(zi, cloze)
print(out_str)
==> grd3_b_cn_all <==
融 róng 融化 融洽 通融 金融
燕 yàn 燕窝 燕子 海燕 燕雀
燕 yān 燕赵 燕山 燕京
鸳 yuān 鸳鸯 枕鸳 双鸳
鸯 yāng 鸳鸯 梁鸯 鸯浆
惠 huì 恩惠 贤惠 惠风 惠临
崇 chóng 崇尚 崇拜 崇高 崇敬
芦 lú 芦苇 芦荟 葫芦 芦席 芦花
芽 yá 麦芽 豆芽 发芽 嫩芽
短 duǎn 短发 短处 短剧 长短
==> grd3_b_cn_zi <==
==> grd3_b_cn_pinyin <==
róng
yàn
yān
yuān
yāng
huì
chóng
duǎn
==> grd3_b_cn_ciyu <==
融化 融洽 通融 金融
燕窝 燕子 海燕 燕雀
燕赵 燕山 燕京
鸳鸯 枕鸳 双鸳
鸳鸯 梁鸯 鸯浆
恩惠 贤惠 惠风 惠临
崇尚 崇拜 崇高 崇敬
芦苇 芦荟 葫芦 芦席 芦花
麦芽 豆芽 发芽 嫩芽
短发 短处 短剧 长短
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment