Class: Ai::Nlp::Language

Inherits:
ApplicationRecord show all
Defined in:
app/models/ai/nlp/language.rb

Overview

Manages a language

Instance Method Summary collapse

Instance Method Details

#add_grams(given_array) ⇒ Object

Add n-grams to the language

Parameters:

  • array

    given_array The array of [gram, frequancy]



15
16
17
18
19
20
# File 'app/models/ai/nlp/language.rb', line 15

def add_grams(given_array)
  given_array.to_h.each do |key, freq|
    map[key] = map[key] ? letters + freq : freq
  end
  update
end