Module: Kotoshu::Algorithms::Suggest

Defined in:
lib/kotoshu/algorithms/suggest.rb

Overview

Main suggestion orchestration for spell checking.

Ported from Spylls (Python) suggest.py

On a bird’s-eye view level, suggest does:

  1. Tries small word “edits” (remove letters, insert letters, swap letters) and checks (with the help of Lookup) if there are any valid ones

  2. If no good suggestions found, tries “ngram-based” suggestions (calculating ngram-based distance to all dictionary words)

  3. If possible, tries metaphone-based suggestions (phonetic)

Note: Spylls’s implementation takes one liberty vs Hunspell: In Hunspell, ngram suggestions and phonetic suggestions are done in the same cycle. Spylls does them in two separate cycles for clarity.

To follow algorithm details, see Suggest.suggestions method.

Defined Under Namespace

Classes: MultiWordSuggestion, Suggester, Suggestion

Constant Summary collapse

MAXPHONSUGS =
2
MAXSUGGESTIONS =
15
GOOD_EDITS =
%w[spaceword uppercase replchars].freeze