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"
# 从低到高;level 取第一个命中的
LISTS = [
("中考", "junior.txt"),
("高考", "senior.txt"),
("CET4", "cet4.txt"),
("CET6", "cet6.txt"),
("TEM4", "tem4.txt"),
("考研", "npee.txt"),
("TEM8", "tem8.txt"),
("IELTS", "ielts.txt"),
("TOEFL", "toefl.txt"),
("GRE", "gre.txt"),
]
ORDER = {name: i for i, (name, _) in enumerate(LISTS)}
# 文件名 → 合并后的级别(与 words 的 8 个级别拉齐;TEM4→CET6, TEM8→GRE, IELTS→TOEFL)
FILE_LEVEL = {
"junior.txt": "中考", "senior.txt": "高考",
"cet4.txt": "CET4", "cet6.txt": "CET6", "npee.txt": "考研",
"tem4.txt": "CET6", "toefl.txt": "TOEFL", "gre.txt": "GRE",
"tem8.txt": "GRE", "ielts.txt": "TOEFL",
}
# 从低到高
LEVELS = ["中考", "高考", "CET4", "CET6", "考研", "TOEFL", "GRE"]
ORDER = {name: i for i, name in enumerate(LEVELS)}
def clean(line: str):
@@ -57,18 +53,15 @@ def clean(line: str):
def build_payload(d: Path) -> tuple[list[dict], dict[str, int]]:
members: dict[str, list[str]] = {}
per = {}
for name, fname in LISTS:
ws = set()
for fname, name in FILE_LEVEL.items():
for ln in (d / "lists" / fname).read_text(encoding="utf-8", errors="replace").splitlines():
p = clean(ln)
if not p:
continue
ws.add(p)
members.setdefault(p, [])
if name not in members[p]:
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):
return ORDER[min(members[p], key=lambda c: ORDER[c])]
BIN
View File
Binary file not shown.