from babregen.spec import similar
print(similar("pase", ["pace", "public", "summary"]))
print(similar("risk", ["pace", "public", "summary"]))pace
None
The one candidate that is close to word, or None.
The match is difflib.get_close_matches with a cutoff of 0.75; word itself is never its own suggestion, and the candidates are sorted first so that the result does not depend on their order.
| Name | Type | Description | Default |
|---|---|---|---|
| word | str | The name that matched nothing. | required |
| candidates | Iterable[str] | The valid names. | required |
| Name | Type | Description |
|---|---|---|
| str | None | str | None: The best match, or None when nothing is close enough. |