lib/langusta/n_gram.rb
# Adds a single character to an NGram sequence.
# @param character [Fixnum] Two-byte Unicode codepoint.
Adds a single character to an NGram sequence.
Adds a single character to an NGram sequence .
def add_char(character)
      Guard.klass(character, Fixnum, __method__)
      Guard.codepoint(character, __method__)
      character = NGram.normalize(character)
      lastchar = @grams[-1]
      if lastchar == UCS2_SPACE
        @grams = [UCS2_SPACE]
        @capitalword = false
        return if character == UCS2_SPACE
      elsif @grams.length > N_GRAM
        @grams = @grams[1..-1]
      end
      @grams << character
      if UnicodeBlock.is_upper_case?(character)
        if UnicodeBlock.is_upper_case?(lastchar)
          @capitalword = true
        end
      else
        @capitalword = false
      end
    end
def add_char ( character ) Guard . klass ( character , Fixnum , __method__ ) Guard . codepoint ( character , __method__ ) character = NGram . normalize ( character ) lastchar = @grams [ - 1 ] if lastchar == UCS2_SPACE @grams = [ UCS2_SPACE ] @capitalword = false return if character == UCS2_SPACE elsif @grams . length > N_GRAM @grams = @grams [ 1 .. - 1 ] end @grams << character if UnicodeBlock . is_upper_case? ( character ) if UnicodeBlock . is_upper_case? ( lastchar ) @capitalword = true end else @capitalword = false end end
Adds a single character to an NGram sequence.
Adds a single character to an NGram sequence .
character
Two-byte Unicode codepoint.
Two - byte Unicode codepoint .