first commit

This commit is contained in:
2026-10-04 11:13:54 +08:00
commit 273c9861a6
197 changed files with 47839 additions and 0 deletions
@@ -0,0 +1,432 @@
# -*- coding: utf-8 -*-
"""
数据库升级:为 kao_yan_3.db 增加主题域与权威搭配。
1. words 表新增 topic 列(主题域:economy/tech/nature/society/education/health/character/daily/general)
2. 新建 collocations 表(词条 ID + 地道搭配 + 中文 + 来源文章编号)
标注范围为已提取的前两组(word_rank 18-217),可重跑(先删旧数据)。
"""
import json
import os
import sqlite3
BASE = os.path.dirname(os.path.abspath(__file__))
DB = os.path.join(BASE, "kao_yan_3.db")
TOPICS = {
# ===== 第一组(18-117)=====
18: "economy", 19: "general", 20: "daily", 21: "tech", 22: "tech",
23: "society", 24: "economy", 25: "character", 26: "daily", 27: "daily",
28: "society", 29: "nature", 30: "general", 31: "general", 32: "general",
33: "general", 34: "society", 35: "daily", 36: "character", 37: "nature",
38: "economy", 39: "daily", 40: "character", 41: "society", 42: "daily",
43: "daily", 44: "general", 45: "society", 46: "education", 47: "general",
48: "nature", 49: "general", 50: "health", 51: "society", 52: "character",
53: "general", 54: "character", 55: "tech", 56: "daily", 57: "tech",
58: "education", 59: "daily", 60: "education", 61: "general", 62: "general",
63: "society", 64: "society", 65: "economy", 66: "daily", 67: "character",
68: "character", 69: "daily", 70: "nature", 71: "general", 72: "society",
73: "general", 74: "general", 75: "tech", 76: "general", 77: "general",
78: "character", 79: "daily", 80: "general", 81: "education", 82: "character",
83: "tech", 84: "nature", 85: "society", 86: "general", 87: "character",
88: "tech", 89: "society", 90: "education", 91: "general", 92: "tech",
93: "tech", 94: "tech", 95: "society", 96: "education", 97: "society",
98: "health", 99: "education", 100: "general", 101: "daily", 102: "daily",
103: "daily", 104: "daily", 105: "society", 106: "daily", 107: "general",
108: "daily", 109: "society", 110: "society", 111: "general", 112: "character",
113: "character", 114: "daily", 115: "general", 116: "society", 117: "daily",
# ===== 第二组(118-217)=====
118: "education", 119: "society", 120: "nature", 121: "daily", 122: "health",
123: "daily", 124: "general", 125: "health", 126: "tech", 127: "general",
128: "health", 129: "character", 130: "daily", 131: "nature", 132: "daily",
133: "nature", 134: "society", 135: "character", 136: "general", 137: "economy",
138: "daily", 139: "daily", 140: "society", 141: "education", 142: "nature",
143: "character", 144: "character", 145: "health", 146: "daily", 147: "education",
148: "health", 149: "general", 150: "society", 151: "character", 152: "health",
153: "daily", 154: "daily", 155: "daily", 156: "education", 157: "general",
158: "society", 159: "education", 160: "tech", 161: "character", 162: "daily",
163: "education", 164: "tech", 165: "daily", 166: "society", 167: "nature",
168: "nature", 169: "general", 170: "nature", 171: "general", 172: "general",
173: "society", 174: "society", 175: "education", 176: "nature", 177: "character",
178: "daily", 179: "daily", 180: "nature", 181: "education", 182: "nature",
183: "economy", 184: "society", 185: "general", 186: "health", 187: "character",
188: "general", 189: "education", 190: "daily", 191: "general", 192: "tech",
193: "economy", 194: "tech", 195: "general", 196: "daily", 197: "tech",
198: "tech", 199: "general", 200: "tech", 201: "society", 202: "daily",
203: "nature", 204: "nature", 205: "daily", 206: "nature", 207: "tech",
208: "general", 209: "economy", 210: "society", 211: "character", 212: "character",
213: "society", 214: "economy", 215: "economy", 216: "general", 217: "nature",
# ===== 第三组(218-317)=====
218: "economy", 219: "tech", 220: "daily", 221: "general", 222: "daily",
223: "society", 224: "character", 225: "character", 226: "daily", 227: "society",
228: "education", 229: "daily", 230: "society", 231: "society", 232: "character",
233: "tech", 234: "society", 235: "nature", 236: "economy", 237: "general",
238: "character", 239: "society", 240: "economy", 241: "general", 242: "tech",
243: "health", 244: "society", 245: "society", 246: "education", 247: "daily",
248: "health", 249: "general", 250: "economy", 251: "education", 252: "society",
253: "society", 254: "daily", 255: "nature", 256: "society", 257: "daily",
258: "daily", 259: "society", 260: "daily", 261: "daily", 262: "daily",
263: "economy", 264: "daily", 265: "society", 266: "tech", 267: "daily",
268: "economy", 269: "general", 270: "daily", 271: "health", 272: "daily",
273: "character", 274: "general", 275: "society", 276: "economy", 277: "society",
278: "daily", 279: "tech", 280: "society", 281: "nature", 282: "economy",
283: "economy", 284: "tech", 285: "society", 286: "daily", 287: "character",
288: "education", 289: "general", 290: "society", 291: "education", 292: "society",
293: "society", 294: "general", 295: "general", 296: "daily", 297: "character",
298: "general", 299: "general", 300: "health", 301: "society", 302: "daily",
303: "general", 304: "daily", 305: "society", 306: "health", 307: "character",
308: "economy", 309: "general", 310: "tech", 311: "tech", 312: "economy",
313: "tech", 314: "society", 315: "society", 316: "economy", 317: "society",
}
# (搭配, 中文) —— 每词 1-2 个地道搭配
COLLOCATIONS = {
18: [("make an investment in", "投资于")],
19: [("coincide with", "与…同时发生/一致")],
20: [("from scratch", "从头开始")],
21: [("circular economy", "循环经济")],
22: [("click on", "点击")],
23: [("cooperative spirit", "合作精神")],
24: [("triple the speed", "三倍速")],
25: [("lose one's temper", "发脾气")],
26: [("rejoice at/in", "为…欢庆")],
27: [("a sideways glance", "侧目一瞥")],
28: [("a legal statute", "法律条文")],
29: [("fall off a cliff", "坠崖")],
30: [("infinite possibilities", "无限可能")],
31: [("suffice it to say", "只需说…就足够")],
32: [("a notable achievement", "显著成就")],
33: [("concede defeat", "认输")],
34: [("elect sb to", "选举某人进入")],
35: [("play golf", "打高尔夫")],
36: [("selfish behavior", "自私行为")],
37: [("evaporate quickly", "迅速蒸发")],
38: [("a planning commission", "规划委员会")],
39: [("climb the staircase", "爬楼梯")],
40: [("a rational decision", "理性决定")],
41: [("carry out a policy", "执行政策")],
42: [("resume work", "复工")],
43: [("body posture", "身体姿态")],
44: [("a downward spiral", "下坠螺旋")],
45: [("artistic value", "艺术价值")],
46: [("a sense of vocation", "职业使命感")],
47: [("come to a halt", "停下")],
48: [("at sunset", "日落时分")],
49: [("it is obvious that", "显而易见")],
50: [("undergo surgery", "接受手术")],
51: [("violent fluctuations", "剧烈波动")],
52: [("resolve a problem", "解决问题")],
53: [("be confronted with", "面对")],
54: [("be faithful to", "忠于")],
55: [("reproduce quickly", "迅速繁殖/复制")],
56: [("huddle together", "挤作一团")],
57: [("the skeleton of", "…的骨架/梗概")],
58: [("digitally illiterate", "数字文盲")],
59: [("at the intersection", "在十字路口")],
60: [("win a scholarship", "获得奖学金")],
61: [("besides, ...", "而且,…")],
62: [("a preposition + noun", "介词+名词")],
63: [("disperse the crowd/fog", "驱散人群/迷雾")],
64: [("implement a plan", "实施计划")],
65: [("export goods", "出口商品")],
66: [("live in a fantasy", "活在幻想中")],
67: [("stay sane", "保持理智")],
68: [("frustrate one's efforts", "挫败某人的努力")],
69: [("gorgeous colors", "绚丽的色彩")],
70: [("soil erosion", "水土流失")],
71: [("ascend the ladder", "登上阶梯")],
72: [("do harm to", "对…有害")],
73: [("provided that", "倘若,只要")],
74: [("be indispensable to", "对…必不可少")],
75: [("through the lens of", "透过…的视角")],
76: [("embody the spirit", "体现精神")],
77: [("nowhere to be found", "无处可寻")],
78: [("motive force", "动力,驱动力")],
79: [("a romantic movie", "浪漫电影")],
80: [("envisage a future", "展望未来")],
81: [("motivate sb to do", "激励某人做")],
82: [("spoil the children", "宠坏孩子")],
83: [("multiply rapidly", "迅速成倍增加")],
84: [("in the pasture", "在牧场")],
85: [("win approval", "获得批准/认可")],
86: [("multiple tasks", "多项任务")],
87: [("a versatile actor", "多才多艺的演员")],
88: [("a magnet for", "吸引…之物")],
89: [("expose sb to", "使某人接触/暴露于")],
90: [("concentrate on", "专心于")],
91: [("A versus B", "A 对 B")],
92: [("population explosion", "人口激增")],
93: [("weld into", "焊接进;融入")],
94: [("up-to-date information", "最新信息")],
95: [("permit sb to do", "允许某人做")],
96: [("a translation of", "…的翻译")],
97: [("medical personnel", "医务人员")],
98: [("cancer screening", "癌症筛查")],
99: [("send a resumé", "投简历")],
100: [("a positive outlook", "积极的心态/前景")],
101: [("splash on", "溅在…上")],
102: [("a summer romance", "夏日恋情")],
103: [("a porcelain vase", "瓷瓶")],
104: [("a product catalog", "产品目录")],
105: [("dispel a myth", "破除误解")],
106: [("a fantastical tale", "神奇的故事")],
107: [("policy implications", "政策影响")],
108: [("wheat flour", "小麦粉")],
109: [("fierce competition", "激烈竞争")],
110: [("have reservations about", "对…持保留态度")],
111: [("block the road", "堵住道路")],
112: [("a cordial welcome", "热忱的欢迎")],
113: [("a timid person", "胆怯的人")],
114: [("by the litre", "按升售卖")],
115: [("propose a plan", "提议一项计划")],
116: [("education reform", "教育改革")],
117: [("razor-sharp", "极为敏锐的")],
118: [("a football coach", "足球教练")],
119: [("a successor to", "…的继任者")],
120: [("pine tree", "松树")],
121: [("a pint of beer/milk", "一品脱啤酒/牛奶")],
122: [("from head to toe", "从头到脚")],
123: [("stagger to one's feet", "蹒跚地站起来")],
124: [("the irony is that", "讽刺的是")],
125: [("apply a bandage", "包扎绷带")],
126: [("scrap metal", "废金属"), ("scrap the plan", "放弃计划")],
127: [("in conjunction with", "与…结合")],
128: [("chronic fatigue syndrome", "慢性疲劳综合征")],
129: [("in an orderly manner", "有条不紊地")],
130: [("tow away", "拖走")],
131: [("a green meadow", "绿色的草地")],
132: [("roast chicken", "烤鸡")],
133: [("haul the harvest", "拉运收成")],
134: [("in succession", "接连地")],
135: [("an energetic person", "精力充沛的人")],
136: [("to no avail", "徒劳无益")],
137: [("household products", "家居产品")],
138: [("a warm quilt", "温暖的被子")],
139: [("apple vinegar", "苹果醋")],
140: [("premier universities", "顶尖大学")],
141: [("intellectual property", "知识产权")],
142: [("reclaim land", "开垦土地")],
143: [("a sarcastic remark", "挖苦的话")],
144: [("cheat in an exam", "考试作弊")],
145: [("permanently disabled", "终身残疾")],
146: [("a wicked witch", "邪恶女巫")],
147: [("tell an anecdote", "讲一件轶事")],
148: [("infect others", "感染他人")],
149: [("a minor issue", "小问题")],
150: [("a traffic cop", "交警")],
151: [("a hostile environment", "敌对环境")],
152: [("a bruise on the leg", "腿上的淤伤")],
153: [("a young lad", "小伙子")],
154: [("pray for", "为…祈祷")],
155: [("crawl forward", "向前爬行")],
156: [("a graduation gown", "学位服")],
157: [("identical twins", "同卵双胞胎")],
158: [("plead guilty", "认罪")],
159: [("lag behind", "落后")],
160: [("industrial automation", "工业自动化")],
161: [("an ambitious goal", "雄心勃勃的目标")],
162: [("a bath towel", "浴巾")],
163: [("academic integrity", "学术诚信")],
164: [("function normally", "正常运转")],
165: [("the final lap", "最后一圈")],
166: [("a representative example", "典型例子")],
167: [("longitude and latitude", "经度和纬度")],
168: [("carrier pigeon", "信鸽")],
169: [("make a comparison", "作比较")],
170: [("hatch eggs", "孵蛋")],
171: [("lest we forget", "以免我们忘记")],
172: [("successive years", "连续数年")],
173: [("fulfill an obligation", "履行义务")],
174: [("graduation ceremony", "毕业典礼")],
175: [("paperback edition", "平装版")],
176: [("watch like a hawk", "像鹰一样紧盯")],
177: [("patriotic spirit", "爱国精神")],
178: [("public lavatory", "公共盥洗室")],
179: [("the exterior of", "…的外部")],
180: [("a troop of", "一群")],
181: [("a shorthand for", "…的简称")],
182: [("natural scenery", "自然风景")],
183: [("levy a tax", "征税")],
184: [("intimidate sb into doing", "胁迫某人做")],
185: [("an effective method", "有效的方法")],
186: [("muscle memory", "肌肉记忆")],
187: [("a generous offer", "慷慨的提议")],
188: [("the possibility of", "…的可能性")],
189: [("a bachelor's degree", "学士学位")],
190: [("a pearl necklace", "珍珠项链")],
191: [("job openings", "职位空缺")],
192: [("probe into", "探究")],
193: [("industrial production", "工业生产")],
194: [("quantitative analysis", "定量分析")],
195: [("a stable condition", "稳定的状况")],
196: [("a soft pillow", "柔软的枕头")],
197: [("harness solar energy", "利用太阳能")],
198: [("sketch a plan", "勾勒计划")],
199: [("respond to", "回应")],
200: [("regular maintenance", "定期维护")],
201: [("a minor incident", "小事件")],
202: [("a hot tub", "热水浴缸")],
203: [("a cluster of", "一簇,一群")],
204: [("prey on", "捕食")],
205: [("tug at", "用力拽")],
206: [("go on an expedition", "去远征/探险")],
207: [("absorb knowledge", "吸收知识")],
208: [("a growing concern", "日益增长的担忧")],
209: [("circulate blood", "血液循环")],
210: [("rectify an error", "纠正错误")],
211: [("personal integrity", "个人诚信")],
212: [("refrain from doing", "克制不做某事")],
213: [("sign a pact", "签署协议")],
214: [("be liable to", "易于…的")],
215: [("merge with", "与…合并")],
216: [("state of mind", "心态")],
217: [("loading dock", "装卸码头")],
218: [("a cargo plane/ship", "货机/货船")],
219: [("a key element of", "…的关键要素")],
220: [("keep pace with", "与…同步/并驾齐驱")],
221: [("it is probable that", "很可能…")],
222: [("exclaim in surprise", "惊讶地喊道")],
223: [("go to the ballet", "去看芭蕾舞")],
224: [("common courtesy", "起码的礼貌")],
225: [("show restraint", "表现出克制")],
226: [("take one's cue from", "以…为榜样/效仿")],
227: [("break a stereotype", "打破成见")],
228: [("enroll in", "注册;入学")],
229: [("the entertainment industry", "娱乐业")],
230: [("legal documents", "法律文件")],
231: [("a cohesive team", "有凝聚力的团队")],
232: [("a dread of", "对…的恐惧")],
233: [("charge a battery", "给电池充电")],
234: [("starve to death", "饿死")],
235: [("a clay pot", "陶罐")],
236: [("promote economic growth", "促进经济增长")],
237: [("a worst-case scenario", "最坏情形")],
238: [("sense of humour", "幽默感")],
239: [("get divorced", "离婚")],
240: [("distribute leaflets", "派发传单")],
241: [("attach importance to", "重视")],
242: [("graphic design", "平面设计")],
243: [("sprain one's ankle", "扭伤脚踝")],
244: [("pass legislation", "通过立法")],
245: [("a confidentiality clause", "保密条款")],
246: [("a pop quiz", "随堂小测")],
247: [("key ingredients", "关键成分")],
248: [("quench one's thirst", "解渴")],
249: [("participate in", "参与")],
250: [("consolidate one's position", "巩固地位")],
251: [("chief librarian", "馆长")],
252: [("a lottery ticket", "彩票")],
253: [("a news reporter", "新闻记者")],
254: [("shove through the crowd", "挤过人群")],
255: [("claw at", "抓挠")],
256: [("mental torture", "精神折磨")],
257: [("the mistress of the house", "女主人")],
258: [("say a prayer", "祈祷")],
259: [("lyric poetry", "抒情诗")],
260: [("clap one's hands", "拍手")],
261: [("purple flowers", "紫色的花")],
262: [("quit one's job", "辞职")],
263: [("be economical with", "节约使用")],
264: [("polish up", "打磨;润色")],
265: [("a cabinet meeting", "内阁会议")],
266: [("optical instruments", "光学仪器")],
267: [("in fashion", "流行")],
268: [("take out insurance", "投保")],
269: [("in principle", "原则上")],
270: [("dazzle the audience", "使观众惊叹")],
271: [("chicken thighs", "鸡腿")],
272: [("lift the lid", "揭开盖子")],
273: [("tedious work", "乏味的工作")],
274: [("a reliable source", "可靠来源")],
275: [("course participants", "课程学员")],
276: [("domestic demand", "内需")],
277: [("initiate a project", "启动项目")],
278: [("glare at", "怒视")],
279: [("compile a report", "汇编报告")],
280: [("without bias", "不带偏见")],
281: [("exhaust fumes", "尾气")],
282: [("price stability", "物价稳定")],
283: [("a tight budget", "紧张的预算")],
284: [("radiate heat", "散发热量")],
285: [("ease tension", "缓解紧张")],
286: [("play chess", "下棋")],
287: [("a moment of reflection", "反思的时刻")],
288: [("on campus", "在校园")],
289: [("the ultimate goal", "终极目标")],
290: [("prosecute sb for", "因…起诉某人")],
291: [("verbal communication", "口头交流")],
292: [("sexual harassment", "性骚扰")],
293: [("the business district", "商业区")],
294: [("overall performance", "整体表现")],
295: [("assume responsibility", "承担责任")],
296: [("salt and pepper", "盐和胡椒")],
297: [("shape one's destiny", "塑造命运")],
298: [("in memory of", "为了纪念")],
299: [("a new concept of", "…的新概念")],
300: [("be resistant to", "对…有抵抗力")],
301: [("natural disaster", "自然灾害")],
302: [("the local grocer", "当地杂货商")],
303: [("enhance the quality", "提升质量")],
304: [("a pail of water", "一桶水")],
305: [("social conventions", "社会习俗")],
306: [("calcium intake", "钙摄入")],
307: [("arouse suspicion", "引起怀疑")],
308: [("make a purchase", "购买")],
309: [("a flat refusal", "断然拒绝")],
310: [("bypass the problem", "绕过问题")],
311: [("silicon chips", "硅芯片")],
312: [("raise funds", "筹集资金")],
313: [("the force of gravity", "重力")],
314: [("a recipient of", "…的接受者")],
315: [("the Commonwealth", "英联邦")],
316: [("public finance", "公共财政")],
317: [("a TV studio", "电视演播室")],
}
def main():
conn = sqlite3.connect(DB)
cur = conn.cursor()
# 1. words 表加 topic 列
cols = [r[1] for r in cur.execute("PRAGMA table_info(words)")]
if "topic" not in cols:
cur.execute("ALTER TABLE words ADD COLUMN topic TEXT")
print("已添加 words.topic 列")
else:
cur.execute("UPDATE words SET topic = NULL")
# 2. 建 collocations 表
cur.executescript("""
DROP TABLE IF EXISTS collocations;
CREATE TABLE collocations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
word_id TEXT NOT NULL,
collocation TEXT NOT NULL,
cn TEXT
);
CREATE INDEX idx_collo_word ON collocations(word_id);
""")
print("已重建 collocations 表")
# 3. 写入 topic 与搭配
n_topic = n_collo = 0
for rank, topic in TOPICS.items():
word_id = f"KaoYan_3_{rank}"
cur.execute("UPDATE words SET topic=? WHERE word_id=?", (topic, word_id))
n_topic += cur.rowcount
for collo, cn in COLLOCATIONS.get(rank, []):
cur.execute(
"INSERT INTO collocations (word_id, collocation, cn) VALUES (?,?,?)",
(word_id, collo, cn),
)
n_collo += 1
conn.commit()
conn.close()
print(f"已标注 topic:{n_topic} 词;已写入搭配:{n_collo} 条")
if __name__ == "__main__":
main()