phrases: merge TEM4->CET6, TEM8->GRE, IELTS->TOEFL (level domain aligns with words)

This commit is contained in:
Lang
2026-10-14 21:33:03 +08:00
parent 42b5df0dc3
commit 211aa6d1c3
2 changed files with 12 additions and 19 deletions
+12 -19
View File
@@ -26,20 +26,16 @@ from import_wordlists import no0_numbers # noqa: E402
DEFAULT_DIR = ROOT / "actions" / "raw" / "english-phrases-main" DEFAULT_DIR = ROOT / "actions" / "raw" / "english-phrases-main"
# 从低到高;level 取第一个命中的 # 文件名 → 合并后的级别(与 words 的 8 个级别拉齐;TEM4→CET6, TEM8→GRE, IELTS→TOEFL)
LISTS = [ FILE_LEVEL = {
("中考", "junior.txt"), "junior.txt": "中考", "senior.txt": "高考",
("高考", "senior.txt"), "cet4.txt": "CET4", "cet6.txt": "CET6", "npee.txt": "考研",
("CET4", "cet4.txt"), "tem4.txt": "CET6", "toefl.txt": "TOEFL", "gre.txt": "GRE",
("CET6", "cet6.txt"), "tem8.txt": "GRE", "ielts.txt": "TOEFL",
("TEM4", "tem4.txt"), }
("考研", "npee.txt"), # 从低到高
("TEM8", "tem8.txt"), LEVELS = ["中考", "高考", "CET4", "CET6", "考研", "TOEFL", "GRE"]
("IELTS", "ielts.txt"), ORDER = {name: i for i, name in enumerate(LEVELS)}
("TOEFL", "toefl.txt"),
("GRE", "gre.txt"),
]
ORDER = {name: i for i, (name, _) in enumerate(LISTS)}
def clean(line: str): def clean(line: str):
@@ -57,18 +53,15 @@ def clean(line: str):
def build_payload(d: Path) -> tuple[list[dict], dict[str, int]]: def build_payload(d: Path) -> tuple[list[dict], dict[str, int]]:
members: dict[str, list[str]] = {} members: dict[str, list[str]] = {}
per = {} for fname, name in FILE_LEVEL.items():
for name, fname in LISTS:
ws = set()
for ln in (d / "lists" / fname).read_text(encoding="utf-8", errors="replace").splitlines(): for ln in (d / "lists" / fname).read_text(encoding="utf-8", errors="replace").splitlines():
p = clean(ln) p = clean(ln)
if not p: if not p:
continue continue
ws.add(p)
members.setdefault(p, []) members.setdefault(p, [])
if name not in members[p]: if name not in members[p]:
members[p].append(name) members[p].append(name)
per[name] = len(ws) per = {lv: sum(1 for cs in members.values() if lv in cs) for lv in LEVELS}
def rank(p): def rank(p):
return ORDER[min(members[p], key=lambda c: ORDER[c])] return ORDER[min(members[p], key=lambda c: ORDER[c])]
BIN
View File
Binary file not shown.