friends: fill example sentences for words/phrases/expressions from corpus; expr column -> translation/usage; drop function/category chips

This commit is contained in:
Lang
2026-10-14 22:42:49 +08:00
parent 7a00485564
commit 9314265958
4 changed files with 118 additions and 9 deletions
+11 -4
View File
@@ -512,10 +512,8 @@ def mine_phrasal(utts: list[str], names: set[str], pmi_min: float = 7.0):
for i in range(len(t) - 2):
if t[i] in COREV and t[i+1] in PART and t[i+2] in PREP:
c3[f"{t[i]} {t[i+1]} {t[i+2]}"] += 1
if t[i] in COREV and t[i+1] in PRO and t[i+2] in PART:
cp[f"{t[i]} {t[i+1]} {t[i+2]}"] += 1
out = {}
for g, n in list(c2.items()) + list(c3.items()) + list(cp.items()):
for g, n in list(c2.items()) + list(c3.items()):
th = 4 if g.count(" ") == 1 else 3
if n >= th and not any(w in names for w in g.split()):
out[g] = max(n, out.get(g, 0))
@@ -558,6 +556,15 @@ def main() -> int:
rows.append({"phrase": g, "fn": "短语动词", "count": n})
rows.sort(key=lambda r: (-r["count"], r["phrase"]))
# 中文译文(人工维护)
zh = {}
zhf = ROOT / "actions" / "raw" / "friends_expr_zh.tsv"
if zhf.exists():
for ln in zhf.read_text(encoding="utf-8").splitlines():
if "\t" in ln:
a, b = ln.split("\t", 1)
zh[a.strip().lower()] = b.strip()
# 用 word 表推 level(取短语里最难的词)
conn = langdb.connect()
wl = {r["item"]: r["level"] for r in conn.execute(
@@ -574,7 +581,7 @@ def main() -> int:
lv = wl[w]
items.append({
"id": "e-" + next(nums), "kind": "expression", "item": r["phrase"],
"level": lv, "meaning": "", "context": f"Friends 全季 ×{r['count']}",
"level": lv, "meaning": zh.get(r["phrase"], ""), "context": "",
"status": "new", "first": "", "fix": "", "function": r["fn"],
"tags": "口语," + r["fn"], "source": "friends:fangj",
"added": today, "hits": 0, "streak": 0, "next_review": None,