pressagio.predictor

Classes for predictors and to handle suggestions and predictions.

class pressagio.predictor.Prediction[source]

Class for predictions from predictors.

Methods

add_suggestion(suggestion)
append L.append(object) – append object to end
count(...)
extend L.extend(iterable) – extend list by appending elements from the iterable
index((value, [start, ...) Raises ValueError if the value is not present.
insert L.insert(index, object) – insert object before index
pop(...) Raises IndexError if list is empty or index is out of range.
remove L.remove(value) – remove first occurrence of value.
reverse L.reverse() – reverse IN PLACE
sort L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE;
suggestion_for_token(token)
__init__()[source]
class pressagio.predictor.Predictor(config, context_tracker, predictor_name, short_desc=None, long_desc=None)[source]

Base class for predictors.

Methods

token_satifies_filter(token, prefix, ...)
__init__(config, context_tracker, predictor_name, short_desc=None, long_desc=None)[source]
class pressagio.predictor.PredictorActivator(config, registry, context_tracker)[source]

PredictorActivator starts the execution of the active predictors, monitors their execution and collects the predictions returned, or terminates a predictor’s execution if it execedes its maximum prediction time.

The predictions returned by the individual predictors are combined into a single prediction by the active Combiner.

Attributes

combination_policy The combination_policy property.

Methods

predict([multiplier, prediction_filter])
__init__(config, registry, context_tracker)[source]
combination_policy[source]

The combination_policy property.

class pressagio.predictor.PredictorRegistry(config, dbconnection=None)[source]

Manages instantiation and iteration through predictors and aids in generating predictions and learning.

PredictorRegitry class holds the active predictors and provides the interface required to obtain an iterator to the predictors.

The standard use case is: Predictor obtains an iterator from PredictorRegistry and invokes the predict() or learn() method on each Predictor pointed to by the iterator.

Predictor registry should eventually just be a simple wrapper around plump.

Attributes

context_tracker The context_tracker property.

Methods

add_predictor(predictor_name)
append L.append(object) – append object to end
close_database()
count(...)
extend L.extend(iterable) – extend list by appending elements from the iterable
index((value, [start, ...) Raises ValueError if the value is not present.
insert L.insert(index, object) – insert object before index
pop(...) Raises IndexError if list is empty or index is out of range.
remove L.remove(value) – remove first occurrence of value.
reverse L.reverse() – reverse IN PLACE
set_predictors()
sort L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE;
__init__(config, dbconnection=None)[source]
context_tracker[source]

The context_tracker property.

class pressagio.predictor.SmoothedNgramPredictor(config, context_tracker, predictor_name, short_desc=None, long_desc=None, dbconnection=None)[source]

Calculates prediction from n-gram model in sqlite database. You have to create a database with the script text2ngram first.

Attributes

database The database property.
deltas The deltas property.
learn_mode The learn_mode property.

Methods

close_database()
init_database_connector_if_ready()
ngram_to_string(ngram)
predict(max_partial_prediction_size, filter)
token_satifies_filter(token, prefix, ...)
__init__(config, context_tracker, predictor_name, short_desc=None, long_desc=None, dbconnection=None)[source]
database[source]

The database property.

deltas[source]

The deltas property.

learn_mode[source]

The learn_mode property.

class pressagio.predictor.Suggestion(word, probability)[source]

Class for a simple suggestion, consists of a string and a probility for that string.

Attributes

probability The probability property.
__init__(word, probability)[source]
probability[source]

The probability property.