Class: Kotoshu::Algorithms::Suggest::MultiWordSuggestion
- Inherits:
-
Object
- Object
- Kotoshu::Algorithms::Suggest::MultiWordSuggestion
- Defined in:
- lib/kotoshu/algorithms/suggest.rb
Overview
Represents suggestion to split words into several.
Used when the algorithm suggests that a misspelled word should be split into multiple dictionary words.
Instance Attribute Summary collapse
-
#allow_dash ⇒ Boolean
readonly
Whether words can be joined by dash.
-
#source ⇒ String
readonly
Same as Suggestion.kind.
-
#words ⇒ Array<String>
readonly
List of words.
Instance Method Summary collapse
-
#initialize(words, source, allow_dash: true) ⇒ MultiWordSuggestion
constructor
A new instance of MultiWordSuggestion.
-
#inspect ⇒ String
Inspect string.
-
#stringify(separator = ' ') ⇒ Suggestion
Convert to string suggestion.
Constructor Details
#initialize(words, source, allow_dash: true) ⇒ MultiWordSuggestion
Returns a new instance of MultiWordSuggestion.
82 83 84 85 86 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 82 def initialize(words, source, allow_dash: true) @words = words @source = source @allow_dash = allow_dash end |
Instance Attribute Details
#allow_dash ⇒ Boolean (readonly)
Returns Whether words can be joined by dash.
80 81 82 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 80 def allow_dash @allow_dash end |
#source ⇒ String (readonly)
Returns Same as Suggestion.kind.
77 78 79 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 77 def source @source end |
#words ⇒ Array<String> (readonly)
Returns List of words.
74 75 76 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 74 def words @words end |
Instance Method Details
#inspect ⇒ String
Inspect string.
99 100 101 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 99 def inspect "Suggestion[#{@source}](#{@words.inspect})" end |
#stringify(separator = ' ') ⇒ Suggestion
Convert to string suggestion.
92 93 94 |
# File 'lib/kotoshu/algorithms/suggest.rb', line 92 def stringify(separator = ' ') Suggestion.new(@words.join(separator), @source) end |