Extract a small set of explicit topic phrases for profile bootstrapping.
(text: str, directions: List[Dict[str, Any]])
| 611 | |
| 612 | |
| 613 | def infer_topics(text: str, directions: List[Dict[str, Any]]) -> List[str]: |
| 614 | """Extract a small set of explicit topic phrases for profile bootstrapping.""" |
| 615 | text_lower = text.lower() |
| 616 | topics = [] |
| 617 | for pattern in TOPIC_PATTERNS: |
| 618 | if pattern in text_lower and pattern not in topics: |
| 619 | topics.append(pattern) |
| 620 | for direction in directions: |
| 621 | normalized = direction["name"].lower() |
| 622 | if normalized not in topics: |
| 623 | topics.append(normalized) |
| 624 | return topics[:8] |
| 625 | |
| 626 | |
| 627 | def parse_pdf(pdf_path: str) -> Dict: |