def extract(query, choices, processor=None, scorer=None, limit=5):
    """Select the best match in a list or dictionary of choices.

    Find best matches in a list or dictionary of choices, return a
    list of tuples containing the match and it's score. If a dictionary
    is used, also returns the key for each match.

    Arguments:
        query: An object representing the thing we want to find.
        choices: An iterable or dictionary-like object containing choices
            to be matched against the query. Dictionary arguments of
            {key: value} pairs will attempt to match the query against
            each value.
        processor: Optional function of the form f(a) -> b, where a is an
            individual choice and b is the choice to be used in matching.

            This can be used to match against, say, the first element of
            a list:

            lambda x: x[0]

            Defaults to fuzzywuzzy.utils.full_process().
        scorer: Optional function for scoring matches between the query and
            an individual processed choice. This should be a function
            of the form f(query, choice) -> int.

            By default, fuzz.WRatio() is used and expects both query and
            choice to be strings.
        limit: Optional maximum for the number of elements returned. Defaults
            to 5.

    Returns:
        List of tuples containing the match and its score.

        If a list is used for choices, then the result will be 2-tuples.
        If a dictionary is used, then the result will be 3-tuples containing
        he key for each match.

        For example, searching for 'bird' in the dictionary

        {'bard': 'train', 'dog': 'man'}

        may return

        [('train', 22, 'bard'), ('man', 0, 'dog')]
    """

    if choices is None:
        return []

    # Catch generators without lengths
    try:
        if len(choices) == 0:
            return []
    except TypeError:
        pass

    # default, turn whatever the choice is into a workable string
    if not processor:
        processor = utils.full_process

    # default: wratio
    if not scorer:
        scorer = fuzz.WRatio

    sl = []

    try:
        # See if choices is a dictionary-like object.
        for key, choice in choices.items():
            processed = processor(choice)
            score = scorer(query, processed)
            sl.append((choice, score, key))
    except __HOLE__:
        # It's a list; just iterate over it.
        for choice in choices:
            processed = processor(choice)
            score = scorer(query, processed)
            sl.append((choice, score))

    sl.sort(key=lambda i: i[1], reverse=True)
    return sl[:limit]
dataset/ETHPy150Open seatgeek/fuzzywuzzy/fuzzywuzzy/process.py/extract