'Return a list of (word, confidence) spelling corrections for the given word,
based on the probability of known words with edit distance 1-2 from the given word.'

def suggest(self, w):

    if (len(self) == 0):
        self.load()
    if (len(w) == 1):
        return [(w, 1.0)]
    if (w in PUNCTUATION):
        return [(w, 1.0)]
    if (w in string.whitespace):
        return [(w, 1.0)]
    if w.replace(u'.', u'').isdigit():
        return [(w, 1.0)]
    candidates = (self._known([w]) or self._known(self._edit1(w)) or self._known(self._edit2(w)) or [w])
    candidates = [(self.get(c, 0.0), c) for c in candidates]
    s = float((sum((p for (p, word) in candidates)) or 1))
    candidates = sorted((((p / s), word) for (p, word) in candidates), reverse=True)
    if w.istitle():
        candidates = [(word.title(), p) for (p, word) in candidates]
    else:
        candidates = [(word, p) for (p, word) in candidates]
    return candidates
