Class: Sooth::Predictor
- Inherits:
-
Object
- Object
- Sooth::Predictor
- Defined in:
- ext/sooth_native/native.c,
ext/sooth_native/native.c
Overview
A very simple stochastic predictor. Implemented in C for efficiency. The idea here is to build up more complicated learning algorithms using a trivial Markovian predictor.
Instance Method Summary collapse
-
#count(bigram) ⇒ Fixnum
Return a count of the number of times the bigram has been observed.
-
#initialize(error_symbol) ⇒ Object
constructor
Returns a new Sooth::Predictor instance.
-
#observe(bigram, symbol) ⇒ Fixnum
Add an observation of the given symbol in the context of the bigram.
-
#select(bigram, limit) ⇒ Fixnum
Return a symbol that may occur in the context of the bigram.
Constructor Details
#initialize(error_symbol) ⇒ Object
Returns a new Sooth::Predictor instance.
40 |
# File 'ext/sooth_native/native.c', line 40 VALUE method_sooth_native_initialize(VALUE self, VALUE error_symbol); |
Instance Method Details
#count(bigram) ⇒ Fixnum
Return a count of the number of times the bigram has been observed.
11 12 13 |
# File 'ext/sooth_native/native.c', line 11 def count(bigram) # (native code) end |
#observe(bigram, symbol) ⇒ Fixnum
Add an observation of the given symbol in the context of the bigram.
52 53 54 |
# File 'ext/sooth_native/native.c', line 52 def observe(bigram, symbol) # (native code) end |
#select(bigram, limit) ⇒ Fixnum
Return a symbol that may occur in the context of the bigram. The limit is used to select a symbol. This is done by iterating through all of the symbols that have been observed in the context of the bigram, subtracting the observation count of each symbol from the supplied limit. For this reason, limit should be between 1 and the observation count of the bigram itself, as returned by #count.
14 15 16 |
# File 'ext/sooth_native/native.c', line 14 def select(bigram, limit) # (native code) end |