Extract meaningful search keywords from a natural-language query.
(query: str)
| 124 | |
| 125 | |
| 126 | def _keywords(query: str) -> list[str]: |
| 127 | """Extract meaningful search keywords from a natural-language query.""" |
| 128 | words = re.findall(r"[a-zA-Z][a-zA-Z0-9]*", query) |
| 129 | seen: set[str] = set() |
| 130 | result: list[str] = [] |
| 131 | for w in words: |
| 132 | lw = w.lower() |
| 133 | if len(lw) >= _KW_MIN_LEN and lw not in _STOPWORDS and lw not in seen: |
| 134 | seen.add(lw) |
| 135 | result.append(w) |
| 136 | return result |
| 137 | |
| 138 | |
| 139 | def _grep_keywords_file_units(query: str, repo_dir: Path) -> list[Chunk]: |
no test coverage detected