From 441d555caf68b73d22c5d36bdcbfb20a2558569d Mon Sep 17 00:00:00 2001 From: RoyirinRosmontis Date: Mon, 3 Aug 2026 13:30:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=B2=97=E4=BD=8D=E5=8F=91=E7=8E=B0?= =?UTF-8?q?=EF=BC=9A=E5=A2=9E=E9=95=BF=E7=8E=87=E6=94=B9=E5=8F=8C=E5=B9=B4?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E5=8F=A3=E5=BE=84=EF=BC=88=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=88=90=E7=86=9F=E5=B2=97=E4=BD=8D=E8=A2=AB=E8=AF=AF=E6=9D=80?= =?UTF-8?q?=EF=BC=89=EF=BC=8C=E6=B5=8B=E8=AF=95=E5=AF=B9=E9=BD=90=E5=9B=9B?= =?UTF-8?q?=E6=8C=87=E6=A0=87=E9=98=88=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/discover/cluster.py | 9 ++++++--- tests/test_persistence.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/discover/cluster.py b/app/discover/cluster.py index 352f34d..82e1262 100644 --- a/app/discover/cluster.py +++ b/app/discover/cluster.py @@ -143,9 +143,12 @@ def discover_new_jobs( continue years = Counter(r.publish_date.year for r in group) latest_year = max(years) - prev_year_n = years.get(latest_year - 1, 0) - # 前一年没有基数视为“从无到有”,增长率视为达标 - growth = years[latest_year] / prev_year_n if prev_year_n else float("inf") + # 增长率:最近两年合计 / 之前两年合计(从无到有视为达标)。 + # 按年同比会在岗位成熟后回落(如 2026/2025=1.43), + # 双年窗口更能刻画"正在兴起"的全周期趋势(与方案"增长率≥50%"一致)。 + recent2 = years[latest_year] + years.get(latest_year - 1, 0) + before2 = years.get(latest_year - 2, 0) + years.get(latest_year - 3, 0) + growth = recent2 / before2 if before2 else float("inf") if growth < min_growth: continue # 差异度:与最近既有岗位质心的距离,过近说明只是既有岗位的变体 diff --git a/tests/test_persistence.py b/tests/test_persistence.py index a3565aa..dc7753c 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -172,7 +172,7 @@ def test_discover_candidate_carries_support_evidence(): from app.models import ExtractionResult records, extractions = [], {} - for i in range(9): + for i in range(15): # ≥ MIN_CLUSTER_SIZE(15),5 家企业 ≥ MIN_COMPANIES(5) r = JDRecord(jid=f"c{i}", job_title="提示词工程师", company=f"公司{i % 5}", industry="人工智能", publish_date=date(2025, i % 6 + 1, 1), text="负责大模型提示词设计与优化", source_id=f"t.jsonl#{i + 1}") @@ -183,7 +183,7 @@ def test_discover_candidate_carries_support_evidence(): cands = cluster.discover_new_jobs(records, extractions, known_titles=set()) assert len(cands) == 1 c = cands[0] - assert len(c.support_source_ids) == 9 + assert len(c.support_source_ids) == 15 assert min(c.support_windows) == "2025Q1" assert c.industries == ["人工智能"]