update format

This commit is contained in:
Wolfang Torres
2025-12-21 22:55:46 +08:00
parent 4e8416ec36
commit 15871e8f59
5 changed files with 37 additions and 62 deletions

15
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Module",
"type": "debugpy",
"request": "launch",
"module": "anki-hsk-creator"
}
]
}

View File

@@ -1,58 +0,0 @@
to block, to be stuck, to be wedged, customs station, a clip, a fastener, a checkpost, Taiwan pr. [ka3] qiǎ 卡 卡
to accompany, to keep sb company, to assist, old variant of 賠|赔[pei2] péi 陪 陪
nearby; neighboring, (in the) vicinity (of); neighborhood fù jìn 附近 附近
wall (CL:面[mian4],堵[du3]), (slang) to block (a website) (usu. in the passive: 被牆|被墙[bei4 qiang2]) qiáng 墙 牆
to stick, to paste, to post (e.g. on a blog), to keep close to, to fit snugly, to subsidize, allowance (e.g. money for food or housing), sticker, classifier for sticking plaster: strip tiē 贴 貼
to advertise, a commercial, advertisement, CL:項|项[xiang4] guǎng gào 广告 廣告
to line up pái duì 排队 排隊
roughly, probably, rough, approximate, about, general idea dà gài 大概 大概
clerk, shop assistant, CL:個|个[ge4] yíng yè yuán 营业员 營業員
right; correct, towards; at; for, concerning; regarding, to treat (sb a certain way), to face, (bound form) opposite; facing; matching, to match together; to adjust, to fit; to suit, to answer; to reply, to add; to pour in (a fluid), to check; to compare, classifier: couple; pair duì 对 對
(after a verb) a bit; a little (indicating brief duration, or softening the tone, or suggesting giving sth a try), all at once; suddenly yī xià 一下 一下
passport, CL:本[ben3],個|个[ge4] hù zhào 护照 護照
to yield, to permit, to let sb do sth, to have sb do sth, to make sb (feel sad etc), by (indicates the agent in a passive clause, like 被[bei4]) ràng 让 讓
to choose, to pick, to select, to elect xuǎn 选 選
to recharge (money onto a card) chōng zhí 充值 充值
domestic, internal (to a country), civil guó nèi 国内 國內
international guó jì 国际 國際
long distance, long-distance phone call (abbr. for 長途電話|长途电话[chang2 tu2 dian4 hua4]), long-distance coach (abbr. for 長途汽車|长途汽车[chang2 tu2 qi4 che1]) cháng tú 长途 長途
to cost, to spend, fee, wasteful, expenses fèi 费 費
to download, also pr. [xia4zai4] xià zǎi 下载 下載
(computer) software ruǎn jiàn 软件 軟件
hair, Taiwan pr. [fa3] fà 发 髮
text message, SMS duǎn xìn 短信 短信
to receive, to accept, to collect, to put away, to restrain, to stop, in care of (used on address line after name) shōu 收 收
mail, post, email yóu jiàn 邮件 郵件
(after a verb, indicates coming out, completion of an action, or ability to discern or detect) chu lai 出来 出來
to take care of (a matter); to deal with (a task, procedure etc); to organize (an event), to establish; to set up; to manage; to run (an enterprise), (law) to handle; to investigate; to prosecute (a case or suspect), (bound form) office (as in 招辦|招办[zhao1 ban4], admissions office) (abbr. for 辦公室|办公室[ban4 gong1 shi4]) bàn 办 辦
(once) again, also, both... and..., and yet, (used for emphasis) anyway yòu 又 又
habit, custom, usual practice, to be used to, CL:個|个[ge4] xí guàn 习惯 習慣
automated teller machine (ATM) zì dòng qǔ kuǎn jī 自动取款机 自動取款機
to take, to get, to choose, to fetch qǔ 取 取
can, to be able to, might possibly, ability, (physics) energy néng 能 能
website wǎng zhàn 网站 網站
to be afraid, to fear, to dread, to be unable to endure, perhaps pà 怕 怕
trouble; inconvenience, inconvenient; troublesome; annoying, to bother sb; to put sb to trouble má fan 麻烦 麻煩
to pay, to hand over to, classifier for pairs or sets of things fù 付 付
method; way; technique; procedure, CL:個|个[ge4] fāng fǎ 方法 方法
battery; electric cell, CL:節|节[jie2],組|组[zu3] diàn chí 电池 電池
battery charger chōng diàn qì 充电器 充電器
express delivery kuài dì 快递 快遞
ought to; should; must yīng gāi 应该 應該
wristwatch, CL:塊|块[kuai4],隻|只[zhi1],個|个[ge4] shǒu biǎo 手表 手錶
to entrust; to place in sb's care, (bound form) to depend on; to attach oneself to; to reside temporarily, (bound form) foster (as in 寄女[ji4 nu : 3] foster daughter), to send by post; to mail jì 寄 寄
(of a period of time) long jiǔ 久 久
last year qù nián 去年 去年
client; customer kè hù 客户 客戶
to serve, service, CL:項|项[xiang4] fú wù 服务 服務
to help, to assist, to support, for sb (i.e. as a help), hired (as worker), side (of pail, boat etc), outer layer, upper (of a shoe), group, gang, clique, party, secret society bāng 帮 幫
typhoon tái 台 颱
air conditioning, air conditioner (including units that have a heating mode), CL:臺|台[tai2] kōng tiáo 空调 空調
recently, soon, nearest zuì jìn 最近 最近
strange, odd, to marvel, to be baffled qí guài 奇怪 奇怪
variant of 修[xiu1] xiū 修 脩
address, CL:個|个[ge4] dì zhǐ 地址 地址
preparation, to prepare, to intend, to be about to, reserve (fund) zhǔn bèi 准备 準備
way of handling sth; means; measure; (practical) solution to a problem, CL:條|条[tiao2],個|个[ge4] bàn fǎ 办法 辦法
to open, to show (a ticket), to turn on, to switch on dǎ kāi 打开 打開
to press, to push, to leave aside or shelve, to control, to restrain, to keep one's hand on, to check or refer to, according to, in the light of, (of an editor or author) to make a comment àn 按 按
1 to block, to be stuck, to be wedged, customs station, a clip, a fastener, a checkpost, Taiwan pr. [ka3] qiǎ
2 to accompany, to keep sb company, to assist, old variant of 賠|赔[pei2] péi
3 nearby; neighboring, (in the) vicinity (of); neighborhood fù jìn 附近 附近
4 wall (CL:面[mian4],堵[du3]), (slang) to block (a website) (usu. in the passive: 被牆|被墙[bei4 qiang2]) qiáng
5 to stick, to paste, to post (e.g. on a blog), to keep close to, to fit snugly, to subsidize, allowance (e.g. money for food or housing), sticker, classifier for sticking plaster: strip tiē
6 to advertise, a commercial, advertisement, CL:項|项[xiang4] guǎng gào 广告 廣告
7 to line up pái duì 排队 排隊
8 roughly, probably, rough, approximate, about, general idea dà gài 大概 大概
9 clerk, shop assistant, CL:個|个[ge4] yíng yè yuán 营业员 營業員
10 right; correct, towards; at; for, concerning; regarding, to treat (sb a certain way), to face, (bound form) opposite; facing; matching, to match together; to adjust, to fit; to suit, to answer; to reply, to add; to pour in (a fluid), to check; to compare, classifier: couple; pair duì
11 (after a verb) a bit; a little (indicating brief duration, or softening the tone, or suggesting giving sth a try), all at once; suddenly yī xià 一下 一下
12 passport, CL:本[ben3],個|个[ge4] hù zhào 护照 護照
13 to yield, to permit, to let sb do sth, to have sb do sth, to make sb (feel sad etc), by (indicates the agent in a passive clause, like 被[bei4]) ràng
14 to choose, to pick, to select, to elect xuǎn
15 to recharge (money onto a card) chōng zhí 充值 充值
16 domestic, internal (to a country), civil guó nèi 国内 國內
17 international guó jì 国际 國際
18 long distance, long-distance phone call (abbr. for 長途電話|长途电话[chang2 tu2 dian4 hua4]), long-distance coach (abbr. for 長途汽車|长途汽车[chang2 tu2 qi4 che1]) cháng tú 长途 長途
19 to cost, to spend, fee, wasteful, expenses fèi
20 to download, also pr. [xia4zai4] xià zǎi 下载 下載
21 (computer) software ruǎn jiàn 软件 軟件
22 hair, Taiwan pr. [fa3]
23 text message, SMS duǎn xìn 短信 短信
24 to receive, to accept, to collect, to put away, to restrain, to stop, in care of (used on address line after name) shōu
25 mail, post, email yóu jiàn 邮件 郵件
26 (after a verb, indicates coming out, completion of an action, or ability to discern or detect) chu lai 出来 出來
27 to take care of (a matter); to deal with (a task, procedure etc); to organize (an event), to establish; to set up; to manage; to run (an enterprise), (law) to handle; to investigate; to prosecute (a case or suspect), (bound form) office (as in 招辦|招办[zhao1 ban4], admissions office) (abbr. for 辦公室|办公室[ban4 gong1 shi4]) bàn
28 (once) again, also, both... and..., and yet, (used for emphasis) anyway yòu
29 habit, custom, usual practice, to be used to, CL:個|个[ge4] xí guàn 习惯 習慣
30 automated teller machine (ATM) zì dòng qǔ kuǎn jī 自动取款机 自動取款機
31 to take, to get, to choose, to fetch
32 can, to be able to, might possibly, ability, (physics) energy néng
33 website wǎng zhàn 网站 網站
34 to be afraid, to fear, to dread, to be unable to endure, perhaps
35 trouble; inconvenience, inconvenient; troublesome; annoying, to bother sb; to put sb to trouble má fan 麻烦 麻煩
36 to pay, to hand over to, classifier for pairs or sets of things
37 method; way; technique; procedure, CL:個|个[ge4] fāng fǎ 方法 方法
38 battery; electric cell, CL:節|节[jie2],組|组[zu3] diàn chí 电池 電池
39 battery charger chōng diàn qì 充电器 充電器
40 express delivery kuài dì 快递 快遞
41 ought to; should; must yīng gāi 应该 應該
42 wristwatch, CL:塊|块[kuai4],隻|只[zhi1],個|个[ge4] shǒu biǎo 手表 手錶
43 to entrust; to place in sb's care, (bound form) to depend on; to attach oneself to; to reside temporarily, (bound form) foster (as in 寄女[ji4 nu : 3] foster daughter), to send by post; to mail
44 (of a period of time) long jiǔ
45 last year qù nián 去年 去年
46 client; customer kè hù 客户 客戶
47 to serve, service, CL:項|项[xiang4] fú wù 服务 服務
48 to help, to assist, to support, for sb (i.e. as a help), hired (as worker), side (of pail, boat etc), outer layer, upper (of a shoe), group, gang, clique, party, secret society bāng
49 typhoon tái
50 air conditioning, air conditioner (including units that have a heating mode), CL:臺|台[tai2] kōng tiáo 空调 空調
51 recently, soon, nearest zuì jìn 最近 最近
52 strange, odd, to marvel, to be baffled qí guài 奇怪 奇怪
53 variant of 修[xiu1] xiū
54 address, CL:個|个[ge4] dì zhǐ 地址 地址
55 preparation, to prepare, to intend, to be about to, reserve (fund) zhǔn bèi 准备 準備
56 way of handling sth; means; measure; (practical) solution to a problem, CL:條|条[tiao2],個|个[ge4] bàn fǎ 办法 辦法
57 to open, to show (a ticket), to turn on, to switch on dǎ kāi 打开 打開
58 to press, to push, to leave aside or shelve, to control, to restrain, to keep one's hand on, to check or refer to, according to, in the light of, (of an editor or author) to make a comment àn

View File

@@ -4,6 +4,7 @@ import csv
from cedict_utils.cedict import CedictParser
from pinyin_tone_converter.pinyin_tone_converter import PinyinToneConverter
# from genanki import Deck, Note
## Constants
@@ -25,21 +26,38 @@ def main():
dictionary = {}
for entry in entries:
dictionary[entry.simplified] = entry
if entry.simplified not in dictionary:
dictionary[entry.simplified] = [entry]
else:
dictionary[entry.simplified].append(entry)
results = []
for word in TEXT.split():
if v := dictionary.get(word):
if len(v) > 1:
print(
f"ERROR: {word} has multiple meanings: \n"
)
for n, w in enumerate(v):
print(f"{n+1} - {w}")
for m in w.meanings:
print(f"\t{m}")
s = None
while not s or not s.isnumeric() or not (1 <= int(s) <= len(v)):
s = input(f"Please select the correct word [1-{len(v)}]: ")
v = v[int(s)-1]
else:
v = v[0]
results.append(v)
else:
print(f"ERROR: {word} not found")
with OUTPUT.open("w", encoding='utf8', newline="") as csvfile:
writer = csv.writer(csvfile, delimiter='\t', quotechar='"')
with OUTPUT.open("w", encoding="utf8", newline="") as csvfile:
writer = csv.writer(csvfile, delimiter="\t", quotechar='"')
for entry in results:
writer.writerow(
[
", ".join(entry.meanings),
"\n ".join(f"{n}. {m}" for i,m in enumerate(entry.meanings)),
PinyinToneConverter().convert_text(entry.pinyin),
entry.simplified,
entry.traditional,