Package tipy :: Module slct :: Class Selector
[hide private]
[frames] | no frames]

Class Selector

source code

object --+
         |
        Selector

The Selector class select the best suggested words among all.

The goal of the selector is to clean the suggested words list (contained in a Prediction instance which should have been returned by a Merger merge() method and remove the words which are too much (the configuration specify the excpected number of suggested words).

Class Hierarchy for Selector
Class Hierarchy for Selector

Instance Methods [hide private]
 
__init__(self, config, contextMonitor)
Selector creator.
source code
 
select(self, prediction)
Select suggested words in the suggestions list.
source code
 
rm_duplicate(self, words)
Remove duplicate words in the list and keep the original order.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, config, contextMonitor)
(Constructor)

source code 

Selector creator.

Parameters:
  • config (drvr.Configuration) - The configuration dictionary is used in order to retrieve the Selector settings from the config file.
  • contextMonitor (ContextMonitor) - The ContextMonitor is used to check if a context change occure. In which case the suggested words list must be cleared because prediction fully depends on the context.
Overrides: object.__init__

select(self, prediction)

source code 

Select suggested words in the suggestions list.

Selecting suggested words consists in:

  • List every suggestions words.
  • Remove duplicate suggested words.
  • Shorten the suggested words list so that it contains the desired number og suggested words.
Parameters:
  • prediction (Prediction) - The list of suggestions from which to carry out the selection.

rm_duplicate(self, words)

source code 

Remove duplicate words in the list and keep the original order.

Parameters:
  • words (list) - The words to filter.