Class: Kotoshu::Components::PassthroughSpellChecker
- Inherits:
-
SpellChecker
- Object
- SpellChecker
- Kotoshu::Components::PassthroughSpellChecker
- Defined in:
- lib/kotoshu/components/passthrough_spell_checker.rb
Overview
Passthrough spell checker for languages that don’t use spell checking.
This checker always returns that words are “found” (correct). It’s used for languages that don’t have traditional spell checking, such as:
-
CJK languages (Japanese, Chinese) - use confusion rules instead
-
Languages with purely rule-based checking
Instance Method Summary collapse
-
#check(_word) ⇒ Hash
Always returns that the word is “found” (correct).
-
#correct?(_word) ⇒ Boolean
Always returns true (all words are “correct”).
-
#initialize(reason: nil) ⇒ PassthroughSpellChecker
constructor
Create a new passthrough spell checker.
-
#passthrough? ⇒ Boolean
Check if this is a passthrough checker.
-
#reason ⇒ String
Get the reason why spell checking is not used.
-
#suggest(_word, _max_suggestions: 10) ⇒ Array<Hash>
Returns no suggestions.
Constructor Details
#initialize(reason: nil) ⇒ PassthroughSpellChecker
Create a new passthrough spell checker.
26 27 28 |
# File 'lib/kotoshu/components/passthrough_spell_checker.rb', line 26 def initialize(reason: nil) @reason = reason || "Language does not use spell checking" end |
Instance Method Details
#check(_word) ⇒ Hash
Always returns that the word is “found” (correct).
34 35 36 |
# File 'lib/kotoshu/components/passthrough_spell_checker.rb', line 34 def check(_word) { found: true, stem: nil, flags: [] } end |
#correct?(_word) ⇒ Boolean
Always returns true (all words are “correct”).
53 54 55 |
# File 'lib/kotoshu/components/passthrough_spell_checker.rb', line 53 def correct?(_word) true end |
#passthrough? ⇒ Boolean
Check if this is a passthrough checker.
67 68 69 |
# File 'lib/kotoshu/components/passthrough_spell_checker.rb', line 67 def passthrough? true end |
#reason ⇒ String
Get the reason why spell checking is not used.
60 61 62 |
# File 'lib/kotoshu/components/passthrough_spell_checker.rb', line 60 def reason @reason end |
#suggest(_word, _max_suggestions: 10) ⇒ Array<Hash>
Returns no suggestions.
Passthrough spell checkers don’t provide suggestions.
45 46 47 |
# File 'lib/kotoshu/components/passthrough_spell_checker.rb', line 45 def suggest(_word, _max_suggestions: 10) [] end |