Home | Trees | Indices | Help |
|
---|
|
object --+ | Predictor --+ | DictionaryPredictor
Very simple word predictor using a dictionary.
The dictionary is a file containing one word per line. This predictor does not use n-grams and is therefore less effective than the predictors using n-grams because it does not consider context.
![]() |
Class Hierarchy for DictionaryPredictor |
|
|||
Inherited from Predictor | |||
---|---|---|---|
__metaclass__ Metaclass for defining Abstract Base Classes (ABCs). |
|
|||
|
|||
|
|||
|
|||
Prediction |
|
||
|
|||
Inherited from |
|
|||
__abstractmethods__ =
|
|||
Inherited from Predictor | |||
---|---|---|---|
_abc_cache = <_weakrefset.WeakSet object at 0x7f2a42360550>
|
|||
_abc_negative_cache = <_weakrefset.WeakSet object at 0x7f2a423
|
|||
_abc_negative_cache_version = 39
|
|||
_abc_registry = <_weakrefset.WeakSet object at 0x7f2a42360490>
|
|
|||
Inherited from |
|
DictionaryPredictor creator.
Note: The string.lower() and string.strip() methods have a great impact on performance (the profile module show that they require almost 1 second of processing time when calculating suggestions for 10 contexts. So this constructor no more directly use the dictionary file. A database is created instead. Every words of the dictionary are lowered and stripped then added to the database. Doing so, the performance of the predictor are way better. Profiling a script querying suggestions for 10 successive contexts show the improvement profits:
Change Log:
|
Initialize the database connector. Using the database file path, the n-gram maximum size and the learn mode to initialize and open the database. |
Select the dictionary range where words starts with the given prefix. A suggested word must complete the given token, it means that suggested words all start with this token, here called the prefix. This method create a list containing the suggested words for the given prefix, i.e. every words of the dictionary list starting with the prefix. It is easy as the dictionary list is ordered. For instance: If the prefix is: 'hell' And the dictionary list is: ['bird', 'blue', 'given', 'hair', 'hellish', 'hello', 'red', 'zip'] We first remove every words of the list one by one until we reach a word which actualy starts with the prefix 'hell', then we have: ['hellish', 'hello', 'red', 'zip'] Finaly we scan every words of the remaining list and when we reach a word which does not starts with the given prefix then we know that every remaining words won't start with the prefix neither as the list is ordered, so we have: ['hellish', 'hello']
Deprecated: This method has become useless since the words are now stored in a database. |
Complete the actual word or predict the next word using dictionary. Use the input buffers (thanks to contextMonitor) and the word dictionary to predict the most probable suggestions. A suggestion is a word which can:
In order to compute the suggestions, this method:
|
This predictor has no ability to learn.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Jul 14 21:07:50 2015 | http://epydoc.sourceforge.net |