# -*- coding: utf-8 -*-
"""矩阵带货精读语料：找「矩阵 + 商投/佣金/出单」的证据"""
import glob, json, os, re, sys

sys.stdout.reconfigure(encoding="utf-8")
ROOT = r"D:\Deepseek\juzhen2_top"
works = {w["id"]: w for w in json.load(open(os.path.join(ROOT, "_works.json"), encoding="utf-8"))}
MATRIX = re.compile(r"矩阵|多账号|多个号|几个号|30个|三十个|号多")
MONEY = re.compile(r"商投|投流|佣金|出单|赚|收益|单")

rows = []
for fp in glob.glob(os.path.join(ROOT, "comments", "*.json")):
    j = json.load(open(fp, encoding="utf-8"))
    aid = j.get("aweme_id", "")
    for c in j.get("comments", []):
        t = (c.get("text") or "").strip()
        if t and MATRIX.search(t):
            rows.append((c.get("digg") or 0, t, aid))

print(f"矩阵相关评论 {len(rows)} 条\n")
for d, t, aid in sorted(rows, key=lambda x: -x[0])[:20]:
    w = works.get(aid, {})
    print(f"[{d:>3}] {t[:110]}")
    print(f"      —— @{w.get('author','')}《{(w.get('desc') or '')[:40]}》")
