Class: Ai::Nlp::NGram
- Inherits:
-
Object
- Object
- Ai::Nlp::NGram
- Defined in:
- lib/ai/nlp/n_gram/n_gram.rb
Overview
Class for calculating n-grams, storing and exploiting them
Instance Method Summary collapse
-
#calculate(input) ⇒ Object
Calculates the n-gram frequencies for the data set passed as an argument.
-
#hash(input) ⇒ Object
Cuts the data set into a grouping of letters.
Instance Method Details
#calculate(input) ⇒ Object
Calculates the n-gram frequencies for the data set passed as an argument
23 24 25 26 |
# File 'lib/ai/nlp/n_gram/n_gram.rb', line 23 def calculate(input) hash = Hasher.new(input) hash.calculate end |
#hash(input) ⇒ Object
Cuts the data set into a grouping of letters
15 16 17 |
# File 'lib/ai/nlp/n_gram/n_gram.rb', line 15 def hash(input) calculate(input).map { |letters, _gram| letters } end |