pressagio.predictor¶
Classes for predictors and to handle suggestions and predictions.
-
class
pressagio.predictor.
Prediction
[source]¶ Class for predictions from predictors.
Methods
append
(self, object, /)Append object to the end of the list. clear
(self, /)Remove all items from list. copy
(self, /)Return a shallow copy of the list. count
(self, value, /)Return number of occurrences of value. extend
(self, iterable, /)Extend list by appending elements from the iterable. index
(self, value[, start, stop])Return first index of value. insert
(self, index, object, /)Insert object before index. pop
(self[, index])Remove and return item at index (default last). remove
(self, value, /)Remove first occurrence of value. reverse
(self, /)Reverse IN PLACE. sort
(self, /, \*[, key, reverse])Stable sort IN PLACE. add_suggestion suggestion_for_token
-
class
pressagio.predictor.
Predictor
(config, context_tracker, predictor_name, short_desc=None, long_desc=None)[source]¶ Base class for predictors.
Methods
token_satifies_filter
-
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 -
__init__
(self, config, registry, context_tracker)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
combination_policy
¶ 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
append
(self, object, /)Append object to the end of the list. clear
(self, /)Remove all items from list. copy
(self, /)Return a shallow copy of the list. count
(self, value, /)Return number of occurrences of value. extend
(self, iterable, /)Extend list by appending elements from the iterable. index
(self, value[, start, stop])Return first index of value. insert
(self, index, object, /)Insert object before index. pop
(self[, index])Remove and return item at index (default last). remove
(self, value, /)Remove first occurrence of value. reverse
(self, /)Reverse IN PLACE. sort
(self, /, \*[, key, reverse])Stable sort IN PLACE. add_predictor close_database set_predictors -
__init__
(self, config, dbconnection=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
context_tracker
¶ 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 predict token_satifies_filter -
__init__
(self, config, context_tracker, predictor_name, short_desc=None, long_desc=None, dbconnection=None)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
database
¶ The database property.
-
deltas
¶ The deltas property.
-
learn_mode
¶ 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__
(self, word, probability)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
probability
¶ The probability property.