[V10.351] recover private care identity candidates

This commit is contained in:
OoO
2026-05-20 20:34:02 +08:00
parent d030e4cf22
commit 5d38735548
4 changed files with 244 additions and 2 deletions

View File

@@ -1389,13 +1389,103 @@ class CompetitorPriceFeeder:
try:
product = product_map.get(_product_id_key(competitor_product_id))
if not product:
recovered, recovery_terms, recovery_candidate_count = _recover_low_score_with_fresh_search(
crawler,
momo_name,
momo_price=momo_price,
existing_product_id=competitor_product_id,
)
if recovered:
best_product, score, diagnostics = recovered
if getattr(diagnostics, "comparison_mode", "") == "unit_comparable":
self._record_match_attempt(
sku,
momo_name,
momo_product_id=momo_product_id,
momo_price=momo_price,
search_terms=search_terms + [term for term in recovery_terms if term not in search_terms],
candidate_count=max(1, recovery_candidate_count),
attempt_status="refresh_unit_comparable",
best_product=best_product,
best_score=score,
diagnostics=diagnostics,
error_message=_format_match_diagnostics(diagnostics),
source=source,
)
skipped_low += 1
attempts_written += 1
continue
if score >= MIN_MATCH_SCORE and not getattr(diagnostics, "hard_veto", False):
tags = _extract_tags(best_product)
tags.extend(getattr(diagnostics, "tags", []))
for reason in getattr(diagnostics, "reasons", ()) or ():
tags.append(f"match_{reason}")
tags.extend(["refresh_known_identity", "fresh_search_recovery", "missing_known_product_id"])
tags = list(dict.fromkeys(tags))
should_write, write_reason = self._should_upsert_competitor_price(
sku,
best_product,
score,
source=source,
)
attempt_terms = search_terms + [term for term in recovery_terms if term not in search_terms]
if not should_write:
self._record_match_attempt(
sku,
momo_name,
momo_product_id=momo_product_id,
momo_price=momo_price,
search_terms=attempt_terms,
candidate_count=max(1, recovery_candidate_count),
attempt_status="refresh_needs_review",
best_product=best_product,
best_score=score,
diagnostics=diagnostics,
error_message=f"{write_reason}; {_format_match_diagnostics(diagnostics)}",
source=source,
)
skipped_low += 1
attempts_written += 1
continue
tags.append(write_reason)
self._upsert_competitor_price(
sku,
best_product,
score,
tags,
momo_product_id=momo_product_id,
momo_price=momo_price,
diagnostics=diagnostics,
source=source,
)
self._record_match_attempt(
sku,
momo_name,
momo_product_id=momo_product_id,
momo_price=momo_price,
search_terms=attempt_terms,
candidate_count=max(1, recovery_candidate_count),
attempt_status="matched",
best_product=best_product,
best_score=score,
diagnostics=diagnostics,
source=source,
)
matched += 1
history_written += 1
attempts_written += 1
continue
self._record_match_attempt(
sku,
momo_name,
momo_product_id=momo_product_id,
momo_price=momo_price,
search_terms=search_terms,
candidate_count=0,
search_terms=search_terms + [term for term in recovery_terms if term not in search_terms],
candidate_count=max(0, recovery_candidate_count),
attempt_status="refresh_no_result",
error_message=f"PChome product_id not returned: {competitor_product_id}",
source=source,

View File

@@ -37,6 +37,17 @@ NOISE_PHRASES = (
"買1送1",
"限定版",
"璀璨奢金限定版",
"單入任選",
"單入",
"全肌防護",
"經典防護王",
"賦活美學",
"弱酸性",
"植萃複方",
"溫和潤澤護理",
"ph值平衡",
"淨味沐浴乳",
"香氛凝膠",
"任選",
"即期品",
"福利品",
@@ -140,6 +151,16 @@ SEARCH_NOISE_PHRASES = (
"聖誕禮物",
"限定版",
"璀璨奢金限定版",
"單入任選",
"全肌防護",
"經典防護王",
"賦活美學",
"弱酸性",
"植萃複方",
"溫和潤澤護理",
"ph值平衡",
"淨味沐浴乳",
"香氛凝膠",
"母親節",
"父親節",
"情人節",
@@ -200,6 +221,11 @@ SEARCH_IDENTITY_ANCHORS = (
"零粉感超持久粉底棒",
"超持久水光鎖吻唇釉",
"裸光蜜粉餅",
"私密潔膚露",
"私密肌潔膚露",
"男性私密醒肌抑菌噴霧",
"男性私密激淨凝露",
"私密抑菌噴霧",
"絕對完美永生玫瑰逆齡乳霜",
"永生玫瑰逆齡乳霜",
"永生玫瑰霜",
@@ -299,6 +325,8 @@ BRAND_ALIAS_OVERRIDES = {
PRODUCT_TYPES = {
"止汗噴霧": ("止汗爽身噴霧", "爽身噴霧", "止汗噴霧"),
"潔膚露": ("潔膚露", "浴潔露", "護潔露", "沐浴露", "wash"),
"私密噴霧": ("私密噴霧", "抑菌噴霧", "醒肌抑菌噴霧"),
"私密凝露": ("凝露", "激淨凝露", "緊實凝露", "亮白凝露"),
"唇釉": ("唇釉", "唇彩", "lip tint", "lip glaze"),
"粉底棒": ("粉底棒", "foundation stick"),
"精華": ("精華", "精華液", "essence", "serum", "安瓶"),