feat(polymarket): exclude sports markets before category detection
CI/CD / build-and-push (push) Successful in 1m33s

Add _SPORTS_EXCLUSIONS list checked first in _detect_category so NBA/NFL/
MLB/NHL/tennis/golf/UFC/boxing/wrestling/tournament markets never bleed into
politics or events categories. Also removes 'super bowl' from _EVENTS_KEYWORDS
since it's now covered by the sports exclusion.

Keywords excluded: nba, nfl, mlb, nhl, basketball, football, baseball, hockey,
soccer, mvp, rookie of the, championship, super bowl, world series, playoffs,
playoff, tournament, tennis, golf, ufc, boxing, wrestler, wrestling,
slam dunk, home run, touchdown.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
chemavx
2026-04-14 13:03:49 +00:00
parent 7b9c5751ea
commit 324edbe4c8
+19 -1
View File
@@ -82,9 +82,25 @@ class PolymarketClient:
] ]
_EVENTS_KEYWORDS: list[str] = [ _EVENTS_KEYWORDS: list[str] = [
"super bowl", "world cup", "oscar", "nobel", "spacex", "nasa", "world cup", "oscar", "nobel", "spacex", "nasa",
] ]
# Sports markets are excluded entirely — BTC/F&G/GNews have no edge there.
# Checked before any category match so sports don't bleed into politics/events.
_SPORTS_EXCLUSIONS: list[str] = [
" nba ", " nfl ", " mlb ", " nhl ",
"basketball", "football", "baseball", "hockey", "soccer",
" mvp ", "rookie of the", "championship", "super bowl", "world series",
"playoffs", "playoff", "tournament",
"tennis", " golf ", " ufc ", "boxing", "wrestler", "wrestling",
"slam dunk", "home run", "touchdown",
]
@classmethod
def _is_sports(cls, question: str) -> bool:
q = f" {question.lower()} "
return any(kw in q for kw in cls._SPORTS_EXCLUSIONS)
@classmethod @classmethod
def _is_crypto_finance(cls, question: str) -> bool: def _is_crypto_finance(cls, question: str) -> bool:
q = f" {question.lower()} " # pad so edge keywords match cleanly q = f" {question.lower()} " # pad so edge keywords match cleanly
@@ -108,6 +124,8 @@ class PolymarketClient:
@classmethod @classmethod
def _detect_category(cls, question: str) -> str: def _detect_category(cls, question: str) -> str:
"""Return the category label for a market question, or '' if unsupported.""" """Return the category label for a market question, or '' if unsupported."""
if cls._is_sports(question):
return "" # exclude sports regardless of other keyword matches
if cls._is_crypto_finance(question): if cls._is_crypto_finance(question):
return "crypto/finance" return "crypto/finance"
if cls._is_politics(question): if cls._is_politics(question):