(caption: str, *, limit: int = 5)
| 268 | |
| 269 | |
| 270 | def caption_keywords(caption: str, *, limit: int = 5) -> list[str]: |
| 271 | words = re.findall(r"[A-Za-z][A-Za-z-]{3,}", caption.lower()) |
| 272 | picked: list[str] = [] |
| 273 | for word in words: |
| 274 | if word in STOPWORDS or word in picked: |
| 275 | continue |
| 276 | picked.append(word) |
| 277 | if len(picked) >= limit: |
| 278 | break |
| 279 | return picked |
| 280 | |
| 281 | |
| 282 | def match_snippet(page_text: str, needle: str, *, radius: int = 90) -> str: |
no outgoing calls
no test coverage detected