(self, text, limit=5, maxdist=2, prefix=0)
return [sug for _, sug in sugs]
:param text: the text to check. This word will **not** be added to the
            suggestions, even if it appears in the word graph.
        :param limit: only return up to this many suggestions. If there are not
            enough terms in the field within ``maxdist`` of the given word, the
            returned list will be shorter than this number.
        :param maxdist: the largest edit distance from the given word to look
            at. Values higher than 2 are not very effective or efficient.
        :param prefix: require suggestions to share a prefix of this length
            with the given word. This is often justifiable since most
            misspellings do not involve the first letter of the word. Using a
            prefix dramatically decreases the time it takes to generate the
            list of words.
:param text: the text to check. This word will **not** be added to the
            suggestions, even if it appears in the word graph.
        :param limit: only return up to this many suggestions. If there are not
            enough terms in the field within ``maxdist`` of the given word, the
            returned list will be shorter than this number.
        :param maxdist: the largest edit distance from the given word to look
            at. Values higher than 2 are not very effective or efficient.
        :param prefix: require suggestions to share a prefix of this length
            with the given word. This is often justifiable since most
            misspellings do not involve the first letter of the word. Using a
            prefix dramatically decreases the time it takes to generate the
            list of words.
: param text : the text to check . This word will ** not ** be added to the suggestions even if it appears in the word graph . : param limit : only return up to this many suggestions . If there are not enough terms in the field within maxdist of the given word the returned list will be shorter than this number . : param maxdist : the largest edit distance from the given word to look at . Values higher than 2 are not very effective or efficient . : param prefix : require suggestions to share a prefix of this length with the given word . This is often justifiable since most misspellings do not involve the first letter of the word . Using a prefix dramatically decreases the time it takes to generate the list of words .
def suggest(self, text, limit=5, maxdist=2, prefix=0):
        """
        :param text: the text to check. This word will **not** be added to the
            suggestions, even if it appears in the word graph.
        :param limit: only return up to this many suggestions. If there are not
            enough terms in the field within ``maxdist`` of the given word, the
            returned list will be shorter than this number.
        :param maxdist: the largest edit distance from the given word to look
            at. Values higher than 2 are not very effective or efficient.
        :param prefix: require suggestions to share a prefix of this length
            with the given word. This is often justifiable since most
            misspellings do not involve the first letter of the word. Using a
            prefix dramatically decreases the time it takes to generate the
            list of words.
        """

        _suggestions = self._suggestions

        heap = []
        seen = set([text])
        for k in xrange(1, maxdist + 1):
            for item in _suggestions(text, k, prefix):
                if item[1] in seen:
                    continue
                seen.add(item[1])

                # Note that the *higher* scores (item[0]) are better!
                if len(heap) < limit:
                    heappush(heap, item)
                elif item > heap[0]:
                    heapreplace(heap, item)

            # If the heap is already at the required length, don't bother going
            # to a higher edit distance
            if len(heap) >= limit:
                break

        sugs = sorted(heap, key=lambda item: (0 - item[0], item[1]))
        return [sug for _, sug in sugs]
def suggest ( self , text , limit = 5 , maxdist = 2 , prefix = 0 ) : _suggestions = self . _suggestions heap = [ ] seen = set ( [ text ] ) for k in xrange ( 1 , maxdist + 1 ) : for item in _suggestions ( text , k , prefix ) : if item [ 1 ] in seen : continue seen . add ( item [ 1 ] ) # Note that the *higher* scores (item[0]) are better! if len ( heap ) < limit : heappush ( heap , item ) elif item > heap [ 0 ] : heapreplace ( heap , item ) # If the heap is already at the required length, don't bother going # to a higher edit distance if len ( heap ) >= limit : break sugs = sorted ( heap , key = lambda item : ( 0 - item [ 0 ] , item [ 1 ] ) ) return [ sug for _ , sug in sugs ]