MCPcopy Index your code
hub / github.com/clips/pattern / suggest

Method suggest

pattern/text/__init__.py:1771–1785  ·  view source on GitHub ↗

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.

(self, w)

Source from the content-addressed store, hash-verified

1769 return set(w for w in words if w in self)
1770
1771 def suggest(self, w):
1772 """ Return a list of (word, confidence) spelling corrections for the given word,
1773 based on the probability of known words with edit distance 1-2 from the given word.
1774 """
1775 if len(self) == 0:
1776 self.load()
1777 candidates = self._known([w]) \
1778 or self._known(self._edit1(w)) \
1779 or self._known(self._edit2(w)) \
1780 or [w]
1781 candidates = [(self.get(w, 0.0), w) for w in candidates]
1782 s = float(sum(p for p, w in candidates) or 1)
1783 candidates = sorted(((p / s, w) for p, w in candidates), reverse=True)
1784 candidates = [(w, p) for p, w in candidates]
1785 return candidates
1786
1787#### MULTILINGUAL ##################################################################################
1788# The default functions in each language submodule, with an optional language parameter:

Callers 2

suggestFunction · 0.80
test_spellingMethod · 0.80

Calls 7

loadMethod · 0.95
_knownMethod · 0.95
_edit1Method · 0.95
_edit2Method · 0.95
lenFunction · 0.85
sumFunction · 0.85
getMethod · 0.45

Tested by 1

test_spellingMethod · 0.64