Class: Fuzzzy::Ngram::Base

Inherits:
MethodBase show all
Defined in:
lib/fuzzzy/methods/ngram/base.rb

Direct Known Subclasses

Indexer, Searcher

Constant Summary

Constants included from Redis

Redis::INDEX_KEY

Instance Attribute Summary

Attributes inherited from MethodBase

#context

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_typeObject



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