class Elrio::NGramGenerator

Public Class Methods

new(list, n = 1, offset = 0) click to toggle source
# File lib/elrio/n_gram_generator.rb, line 5
def initialize(list, n = 1, offset = 0)
  @offset = offset
  @list = list
  @n = n
end

Public Instance Methods

each() { |list| ... } click to toggle source
# File lib/elrio/n_gram_generator.rb, line 11
def each
  yield @list[0, @offset]

  i = @offset

  while i < @list.size
    yield @list[i, @n]
    i += @n
  end
end