AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
fix(image-search): match transit terms as whole words in the ranking penalty
hugohe3b827c5cea788
diff --git a/skills/ppt-master/scripts/image_sources/provider_common.py b/skills/ppt-master/scripts/image_sources/provider_common.pyindex 26049330..d652d8af 100644--- a/skills/ppt-master/scripts/image_sources/provider_common.py+++ b/skills/ppt-master/scripts/image_sources/provider_common.py@@ -447,6 +447,14 @@ def compute_relevance(candidate: AssetCandidate, query: str) -> float:return hits / len(tokens)+# Whole words only: a bare substring test penalized "business", "trail", and+# "网站", and the text includes author names and source URLs.+_INFRA_TERMS_RE = re.compile(+ r"(?<![a-z])(?:stations?|subways?|metro|rail(?:way|road)?s?|transit"+ r"|airports?|bus(?:es)?)(?![a-z])|地铁|车站|轨道"+)++def score_candidate(candidate: AssetCandidate, request: ImageSearchRequest) -> float:"""Score a candidate against a request. Higher is better; -inf rejects.@@ -485,14 +493,8 @@ def score_candidate(candidate: AssetCandidate, request: ImageSearchRequest) -> f# This prevents high-res subway station photos from outranking actual tourist landmarks.text = _candidate_text(candidate)query_lower = request.query.lower()- infra_terms = [- "station", "subway", "metro", "rail", "transit", "airport", "bus",- "地铁", "站", "轨道",- ]-- if not any(t in query_lower for t in infra_terms):- if any(t in text for t in infra_terms):- score -= 5000.0+ if not _INFRA_TERMS_RE.search(query_lower) and _INFRA_TERMS_RE.search(text):+ score -= 5000.0candidate_orientation = normalize_orientation(candidate.width, candidate.height)requested = (request.orientation or "").strip().lower()diff --git a/skills/ppt-master/scripts/tests/test_image_search.py b/skills/ppt-master/scripts/tests/test_image_search.pyindex bc1bd0f9..a9205ce7 100644--- a/skills/ppt-master/scripts/tests/test_image_search.py+++ b/skills/ppt-master/scripts/tests/test_image_search.py@@ -225,3 +225,35 @@ class CandidatePoolContinuationTests(unittest.TestCase):self.assertEqual(image.format, "JPEG")self.assertEqual(image.size, (48, 64))self.assertNotIn(274, image.getexif())+++class InfrastructurePenaltyTests(unittest.TestCase):+ def _score(self, query: str, title: str) -> float:+ from image_sources.provider_common import (+ LICENSE_TIER_NO_ATTRIBUTION,+ AssetCandidate,+ ImageSearchRequest,+ score_candidate,+ )++ candidate = AssetCandidate(+ provider="test",+ title=title,+ license_tier=LICENSE_TIER_NO_ATTRIBUTION,+ width=1600,+ height=900,+ )+ return score_candidate(candidate, ImageSearchRequest(query=query))++ def test_words_containing_transit_terms_are_not_penalized(self) -> None:+ baseline = self._score("team", "team office")+ for title in ("team business", "team trail", "team 网站"):+ with self.subTest(title=title):+ self.assertEqual(self._score("team", title), baseline)++ def test_transit_photo_is_penalized_unless_requested(self) -> None:+ self.assertLess(+ self._score("team", "team bus station"),+ self._score("team", "team office"),+ )+ self.assertGreater(self._score("bus station", "team bus station"), 0)