(current: str, options: Collection[str], n: int)
| 3374 | |
| 3375 | |
| 3376 | def best_matches(current: str, options: Collection[str], n: int) -> list[str]: |
| 3377 | if not current: |
| 3378 | return [] |
| 3379 | # narrow down options cheaply |
| 3380 | options = [o for o in options if _real_quick_ratio(current, o) > 0.75] |
| 3381 | if len(options) >= 50: |
| 3382 | options = [o for o in options if abs(len(o) - len(current)) <= 1] |
| 3383 | |
| 3384 | ratios = {option: difflib.SequenceMatcher(a=current, b=option).ratio() for option in options} |
| 3385 | options = [option for option, ratio in ratios.items() if ratio > 0.75] |
| 3386 | return sorted(options, key=lambda v: (-ratios[v], v))[:n] |
| 3387 | |
| 3388 | |
| 3389 | def pretty_seq(args: Sequence[str], conjunction: str) -> str: |
no test coverage detected
searching dependent graphs…