Class: Fuzzzy::Ngram::Base
- Inherits:
-
MethodBase
- Object
- MethodBase
- Fuzzzy::Ngram::Base
- Defined in:
- lib/fuzzzy/methods/ngram/base.rb
Constant Summary
Constants included from Redis
Instance Attribute Summary
Attributes inherited from MethodBase
Instance Method Summary collapse
Methods inherited from MethodBase
#index_name, #prepare_string, #stopwords, #with_context
Methods included from Redis
counter_key, #counter_key, #dictionary_key, #redis, #shared_key
Instance Method Details
#index_type ⇒ Object
10 11 12 |
# File 'lib/fuzzzy/methods/ngram/base.rb', line 10 def index_type 'ngram_i' end |
#ngrams(string = nil) ⇒ Object
4 5 6 7 8 |
# File 'lib/fuzzzy/methods/ngram/base.rb', line 4 def ngrams string=nil string ||= query_index_string return [string] if string.size < 3 context[string] ||= (0..string.length-3).map{|idx| string[idx,3] } end |