astropy 5.0

ParametersReturns
did_you_mean(s, candidates, n=3, cutoff=0.8, fix=None)

Parameters

s : str
candidates : sequence of str or dict of str keys
n : int

The maximum number of results to include. See difflib.get_close_matches .

cutoff : float

In the range [0, 1]. Possibilities that don't score at least that similar to word are ignored. See difflib.get_close_matches .

fix : callable

A callable to modify the results after matching. It should take a single string and return a sequence of strings containing the fixed matches.

Returns

message : str

Returns the string "Did you mean X, Y, or Z?", or the empty string if no alternatives were found.

When a string isn't found in a set of candidates, we can be nice to provide a list of alternatives in the exception. This convenience function helps to format that part of the exception.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /astropy/utils/misc.py#424
type: <class 'function'>
Commit: