Class: DidYouMean::TreeSpellChecker
- Inherits:
-
Object
- Object
- DidYouMean::TreeSpellChecker
- Defined in:
- lib/did_you_mean/tree_spell_checker.rb
Overview
spell checker for a dictionary that has a tree structure, see doc/tree_spell_checker_api.md
Instance Attribute Summary collapse
-
#augment ⇒ Object
readonly
Returns the value of attribute augment.
-
#dictionary ⇒ Object
readonly
Returns the value of attribute dictionary.
-
#dimensions ⇒ Object
readonly
Returns the value of attribute dimensions.
-
#separator ⇒ Object
readonly
Returns the value of attribute separator.
Instance Method Summary collapse
- #correct(input) ⇒ Object
-
#initialize(dictionary:, separator: '/', augment: nil) ⇒ TreeSpellChecker
constructor
A new instance of TreeSpellChecker.
Constructor Details
#initialize(dictionary:, separator: '/', augment: nil) ⇒ TreeSpellChecker
Returns a new instance of TreeSpellChecker.
7 8 9 10 11 12 |
# File 'lib/did_you_mean/tree_spell_checker.rb', line 7 def initialize(dictionary:, separator: '/', augment: nil) @dictionary = dictionary @separator = separator @augment = augment @dimensions = parse_dimensions end |
Instance Attribute Details
#augment ⇒ Object (readonly)
Returns the value of attribute augment.
5 6 7 |
# File 'lib/did_you_mean/tree_spell_checker.rb', line 5 def augment @augment end |
#dictionary ⇒ Object (readonly)
Returns the value of attribute dictionary.
5 6 7 |
# File 'lib/did_you_mean/tree_spell_checker.rb', line 5 def dictionary @dictionary end |
#dimensions ⇒ Object (readonly)
Returns the value of attribute dimensions.
5 6 7 |
# File 'lib/did_you_mean/tree_spell_checker.rb', line 5 def dimensions @dimensions end |
#separator ⇒ Object (readonly)
Returns the value of attribute separator.
5 6 7 |
# File 'lib/did_you_mean/tree_spell_checker.rb', line 5 def separator @separator end |
Instance Method Details
#correct(input) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/did_you_mean/tree_spell_checker.rb', line 14 def correct(input) plausibles = plausible_dimensions input return no_idea(input) if plausibles.empty? suggestions = find_suggestions input, plausibles return no_idea(input) if suggestions.empty? suggestions end |