mirror of
https://github.com/primedigitaltech/market-assistant.git
synced 2026-07-22 16:11:38 +08:00
- 统一 csv_schema 与搜索/合并/评价/商详导出为纯中文列名,入库与视图按中文表头解析 - 竞品分析报告兼容新旧表头;新增 csv_header_rewrite 与 rewrite_pipeline_csv_headers 管理命令 - 调整 pipeline 至 jd、llm、reporting、demos 子包并更新任务与测试引用 - 新增购买者优惠摘要抽取、合并表 regen/ingest 命令、0016 迁移及相关测试 Made-with: Cursor
25 lines
820 B
Python
25 lines
820 B
Python
"""竞品简报「集中度」块:对外字段名面向非技术用户,并兼容旧键名。"""
|
||
from __future__ import annotations
|
||
|
||
from typing import Any
|
||
|
||
|
||
def concentration_first_share(block: dict[str, Any] | None) -> Any:
|
||
"""最大一家占全部相关行的比例(0~1)。新键 ``first_share``,旧键 ``cr1``。"""
|
||
if not block:
|
||
return None
|
||
v = block.get("first_share")
|
||
if v is not None:
|
||
return v
|
||
return block.get("cr1")
|
||
|
||
|
||
def concentration_top_three_share(block: dict[str, Any] | None) -> Any:
|
||
"""前三名合计占全部相关行的比例(0~1)。新键 ``top_three_combined_share``,旧键 ``cr3``。"""
|
||
if not block:
|
||
return None
|
||
v = block.get("top_three_combined_share")
|
||
if v is not None:
|
||
return v
|
||
return block.get("cr3")
|