Module: Entropic
- Defined in:
- lib/entropic.rb,
lib/entropic/version.rb
Overview
Public: classes and methods useful for estimating entropy on strings.
Examples
model = Entropic.Model.read("ngrams.tsv")
model.predict("the")
# => { log_prob_total: -101.1, log_prob_average: -20.02, size: 5 }
Defined Under Namespace
Classes: Model, NGramCounter
Constant Summary collapse
- VERSION =
"0.2.1"
Class Method Summary collapse
-
.sliding(string, n) ⇒ Object
Public: create a sliding window of ngrams from a string.
Class Method Details
.sliding(string, n) ⇒ Object
Public: create a sliding window of ngrams from a string
string: The String to slide over n: The Integer defining the size of the ngrams
Examples
sliding('01234', 2)
# => ['01', '12', '23', '34']
22 23 24 |
# File 'lib/entropic.rb', line 22 def self.sliding(string, n) (0..string.length - n).map { |i| (string[i, n]).to_s } end |