Method: BagOfWords.bigrams

Defined in:
lib/rbbt/bow/bow.rb

.bigrams(text) ⇒ Object

Take the array of words for the text and form all the bigrams



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rbbt/bow/bow.rb', line 29

def self.bigrams(text)
  words = words(text)
  bigrams = []
  lastword = nil

  words.each{|word|
    if lastword
      bigrams << "#{lastword} #{word}"
    end
    lastword = word
  }

  words + bigrams
end