events: editorial output of media publishers is not a corporate communication event
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 changed file +15 −1
modified
src/companyatlas/services/events.py
+15 −1
@@ -658,6 +658,17 @@ def _text_diff_rules(surface: str, change: dict[str, Any], diff: dict[str, Any], | ||
| 658 | 658 | # ============================================================================================================== derive |
| 659 | 659 | |
| 660 | 660 | |
| 661 | + | |
| 662 | +# Media / entertainment / gaming publishers: their "news" and "blog" surfaces ARE their product (articles, live tickers, videos) — a new | |
| 663 | +# article is not a corporate communication event. Their items still land in `news_items` for the profile; only event generation is skipped. | |
| 664 | +MEDIA_PUBLISHER_INDUSTRIES = frozenset({"media", "entertainment", "gaming", "publishing", "broadcasting", "news-media"}) | |
| 665 | + | |
| 666 | + | |
| 667 | +def _is_media_publisher(company: dict[str, Any]) -> bool: | |
| 668 | + inds = {str(i) for i in (company.get("industries") or [])} | |
| 669 | + return bool(inds & MEDIA_PUBLISHER_INDUSTRIES) or str(company.get("industry_primary") or "") in MEDIA_PUBLISHER_INDUSTRIES | |
| 670 | + | |
| 671 | + | |
| 661 | 672 | def derive_events(change: dict[str, Any], company: dict[str, Any], sensor: dict[str, Any], *, baseline: dict[str, Any] | None = None, |
| 662 | 673 | country_names: dict[str, str] | None = None) -> Derived: |
| 663 | 674 | """Pure rule evaluation for one change. Returns drafts with importance/confidence finalised, plus LLM hints.""" |
@@ -677,7 +688,10 @@ def derive_events(change: dict[str, Any], company: dict[str, Any], sensor: dict[ | ||
| 677 | 688 | drafts += _leadership_rules(delta, surface, evidence) |
| 678 | 689 | drafts += _product_rules(delta, evidence) |
| 679 | 690 | drafts += _location_rules(delta, evidence, names) |
| 680 | − drafts += _news_rules(delta, surface, evidence) | |
| 691 | + if not _is_media_publisher(company): | |
| 692 | + drafts += _news_rules(delta, surface, evidence) | |
| 693 | + elif (delta.get("news") or {}).get("added"): | |
| 694 | + change.setdefault("notes", []).append("editorial items of a media publisher are not corporate communication events") | |
| 681 | 695 | structured_hit = bool(drafts) |
| 682 | 696 | if not structured_hit: |
| 683 | 697 | drafts += _text_diff_rules(surface, change, diff, delta) |
| 684 | 698 | |