|
@@ -539,6 +539,7 @@ async def maintain_subject(item: dict[str, Any], dry_run: bool, refresh_payloads
|
|
|
wiki_description = (full.get("description") or "").strip()
|
|
wiki_description = (full.get("description") or "").strip()
|
|
|
current_label = subject.strip()
|
|
current_label = subject.strip()
|
|
|
current_mid = item.get("mid")
|
|
current_mid = item.get("mid")
|
|
|
|
|
+ qid = full.get("qid")
|
|
|
wikidata_mid = None
|
|
wikidata_mid = None
|
|
|
claims = entity_block.get("claims", {}) if isinstance(entity_block, dict) else {}
|
|
claims = entity_block.get("claims", {}) if isinstance(entity_block, dict) else {}
|
|
|
mid_claims = claims.get("P2671", []) if isinstance(claims, dict) else []
|
|
mid_claims = claims.get("P2671", []) if isinstance(claims, dict) else []
|
|
@@ -597,9 +598,10 @@ async def maintain_subject(item: dict[str, Any], dry_run: bool, refresh_payloads
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- # If Wikidata does not provide a MID, try the Trends candidates as a
|
|
|
|
|
- # fallback. Wikidata wins whenever it has a MID.
|
|
|
|
|
- if not wikidata_mid:
|
|
|
|
|
|
|
+ # If Wikidata does not provide a MID, Trends can be used only as a
|
|
|
|
|
+ # last resort. If we already have a Wikidata QID hit, do NOT inject
|
|
|
|
|
+ # a Trends MID (prevents Graza-style cross-entity contamination).
|
|
|
|
|
+ if not wikidata_mid and not qid:
|
|
|
trends_candidates = []
|
|
trends_candidates = []
|
|
|
raw_trends = item.get("raw_trends_json")
|
|
raw_trends = item.get("raw_trends_json")
|
|
|
if raw_trends:
|
|
if raw_trends:
|
|
@@ -628,7 +630,6 @@ async def maintain_subject(item: dict[str, Any], dry_run: bool, refresh_payloads
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
# QID is always a known cross-reference and acts as a stable anchor.
|
|
# QID is always a known cross-reference and acts as a stable anchor.
|
|
|
- qid = full.get("qid")
|
|
|
|
|
existing_qid = None
|
|
existing_qid = None
|
|
|
if qid and qid != existing_qid:
|
|
if qid and qid != existing_qid:
|
|
|
claim = AtlasClaim(
|
|
claim = AtlasClaim(
|