Pull non-stopword tokens from text, deduplicated.
(text: str)
| 18 | |
| 19 | |
| 20 | def extract_keywords(text: str) -> list: |
| 21 | """Pull non-stopword tokens from text, deduplicated.""" |
| 22 | tokens = re.findall(r"\b[a-z]{3,}\b", normalize_text(text)) |
| 23 | seen = set() |
| 24 | keywords = [] |
| 25 | for t in tokens: |
| 26 | if t not in STOPWORDS and t not in seen: |
| 27 | seen.add(t) |
| 28 | keywords.append(t) |
| 29 | return keywords |
| 30 | |
| 31 | |
| 32 | def enrich_document(doc: dict) -> dict: |
no test coverage detected