Returns a set of words with edit distance 2 from the given word
(self, w)
| 1757 | return set(delete + transpose + replace + insert) |
| 1758 | |
| 1759 | def _edit2(self, w): |
| 1760 | """ Returns a set of words with edit distance 2 from the given word |
| 1761 | """ |
| 1762 | # Of all spelling errors, 99% is covered by edit distance 2. |
| 1763 | # Only keep candidates that are actually known words (20% speedup). |
| 1764 | return set(e2 for e1 in self._edit1(w) for e2 in self._edit1(e1) if e2 in self) |
| 1765 | |
| 1766 | def _known(self, words=[]): |
| 1767 | """ Returns the given list of words filtered by known words. |