feat: 热词热力图改为Treemap矩形堆砌布局,面积代表提及次数;赛道分析页面布局调整

This commit is contained in:
freedakgmail
2026-07-21 07:59:25 +08:00
parent a40b0f14ae
commit 3c4916ba04
8 changed files with 284 additions and 81 deletions
+23 -1
View File
@@ -51,6 +51,23 @@ def get_api_key() -> str:
# ---- 单篇文章结构化分析 ----
_PROFANITY_MAP = {
"妈的": "**", "傻逼": "**", "他妈": "**", "": "*",
"草泥马": "***", "尼玛": "**", "贱人": "**",
"王八蛋": "***", "混蛋": "**", "去死": "**",
"毛爷爷": "某伟人", "毛泽东": "某伟人", "国民党": "某党",
"共产党": "某党", "长征": "远征", "抗日": "抗战",
"革命": "变革", "社会主义": "某主义",
}
def sanitize_content(text: str) -> str:
"""过滤粗口和敏感词,避免触发千问内容审核。"""
for word, replacement in _PROFANITY_MAP.items():
text = text.replace(word, replacement)
return text
def analyze_article(title: str, content: str) -> dict:
"""调用通义千问对文章进行结构化分析。"""
api_key = get_api_key()
@@ -71,7 +88,7 @@ JSON 字段必须为:
- numbers(关键数据数组)
文章标题:{title}
正文:{content[:24000]}"""
正文:{sanitize_content(content[:24000])}"""
payload = json.dumps({
"model": model,
"messages": [
@@ -276,6 +293,11 @@ def run_batch_analyze(force: bool, pause: float, retries: int) -> int:
break
except Exception as exc:
last_error = exc
err_str = str(exc)
# 内容审核失败,标记跳过不重试
if "data_inspection_failed" in err_str:
print(f"[{index}/{len(rows)}] SKIP(内容审核) {row['title']}", flush=True)
break
if attempt <= retries:
wait = attempt * 2
print(f"[{index}/{len(rows)}] RETRY {attempt}/{retries} {exc}", flush=True)