Selector Class Reference

#include <selector.h>

Inheritance diagram for Selector:
Inheritance graph
[legend]
Collaboration diagram for Selector:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Selector (Configuration *, ContextTracker *)
 ~Selector ()
std::vector< std::string > select (Prediction)
void update ()
void set_logger (const std::string &value)
void set_suggestions (const std::string &value)
void set_repeat_suggestions (const std::string &value)
void set_greedy_suggestion_threshold (const std::string &value)
size_t get_suggestions () const
bool get_repeat_suggestions () const
size_t get_greedy_suggestion_threshold () const
virtual void update (const Observable *variable)

Static Public Attributes

static const char * LOGGER = "Presage.Selector.LOGGER"
static const char * SUGGESTIONS = "Presage.Selector.SUGGESTIONS"
static const char * REPEAT_SUGGESTIONS = "Presage.Selector.REPEAT_SUGGESTIONS"
static const char * GREEDY_SUGGESTION_THRESHOLD = "Presage.Selector.GREEDY_SUGGESTION_THRESHOLD"

Private Types

typedef void(Selector::* mbr_func_ptr_t )(const std::string &)

Private Member Functions

void updateSuggestedWords (const std::vector< std::string > &)
void clearSuggestedWords ()
void repetitionFilter (std::vector< std::string > &)
void thresholdFilter (std::vector< std::string > &)

Private Attributes

std::map< std::string,
mbr_func_ptr_t
dispatch_map
size_t suggestions
bool repeat_suggestions
size_t greedy_suggestion_threshold
StringSet suggestedWords
std::string previous_prefix
ContextTrackercontextTracker
Configurationconfig
Logger< char > logger
Dispatcher< Selectordispatcher

Detailed Description

Selector selects which suggestions supplied by Predictor should be given to the user.

Suggestions selection is performed based on users preferences. Preferences are read from configuration and provided by Configuration.

Selected suggestions are returned to the outside world.

Customisable settings:

SUGGESTIONS: integer, number of suggestions to be selected

REPEAT_SUGGESTIONS: boolean, controls whether a predicted token should be suggested to the user once or multiple times, if its prediction occurs within the same predictive context. A predictive context corresponds to the set of suggestions computed when predicting the same word (token). Some users may fail to see the desired suggestion and might benefit from the fact that the same token will be suggested again if it ranks high in the prediction. If this option is enabled, Selector remembers which tokens have been suggested in the current token and filters out suggestions that have already been selected.

GREEDY_SUGGESTION_THRESHOLD: integer, only tokens whose completion is longer than the specified number of characters are selected. The rationale behind this option is that a user might prefer to be offered a longer word before a shorter word, because typing a longer word is more time-consuming.

For example, given a threshold=2 and prefix="automa", token "automatically" would be suggested, while "automatic" would not.

Definition at line 80 of file selector.h.


Member Typedef Documentation

typedef void(Selector::* Selector::mbr_func_ptr_t)(const std::string &) [private]

Definition at line 107 of file selector.h.


Constructor & Destructor Documentation

Selector::Selector ( Configuration configuration,
ContextTracker ct 
)
Selector::~Selector (  ) 

Definition at line 50 of file selector.cpp.


Member Function Documentation

void Selector::clearSuggestedWords (  )  [private]

Clear the set of previously selected suggestions.

Definition at line 131 of file selector.cpp.

References endl(), logger, and suggestedWords.

Referenced by select(), and update().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t Selector::get_greedy_suggestion_threshold (  )  const

Definition at line 256 of file selector.cpp.

References greedy_suggestion_threshold.

bool Selector::get_repeat_suggestions (  )  const

Definition at line 251 of file selector.cpp.

References repeat_suggestions.

size_t Selector::get_suggestions (  )  const

Definition at line 246 of file selector.cpp.

References suggestions.

Referenced by Presage::predict().

Here is the caller graph for this function:

void Selector::repetitionFilter ( std::vector< std::string > &  v  )  [private]

Filters out suggestions that have previously been selected in the current context.

This filter removes the suggestions that have previously been selected. The set of suggestions that were previously selected is stored in suggestedWords. This filters removes the words that are contained in both

Parameters:
v and suggestedWords.

Definition at line 145 of file selector.cpp.

References endl(), logger, and suggestedWords.

Referenced by select().

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< std::string > Selector::select ( Prediction  p  ) 
void Selector::set_greedy_suggestion_threshold ( const std::string &  value  ) 

Set SUGGESTION_THRESHOLD option.

Definition at line 233 of file selector.cpp.

References endl(), greedy_suggestion_threshold, logger, and Utility::toInt().

Referenced by Selector().

Here is the call graph for this function:

Here is the caller graph for this function:

void Selector::set_logger ( const std::string &  value  ) 

Set LOGGER option.

Definition at line 194 of file selector.cpp.

References endl(), logger, and setlevel().

Referenced by Selector().

Here is the call graph for this function:

Here is the caller graph for this function:

void Selector::set_repeat_suggestions ( const std::string &  value  ) 

Set REPEAT_SUGGESTION option.

Definition at line 221 of file selector.cpp.

References endl(), Utility::isYes(), logger, and repeat_suggestions.

Referenced by Selector().

Here is the call graph for this function:

Here is the caller graph for this function:

void Selector::set_suggestions ( const std::string &  value  ) 

Set SUGGESTIONS option.

Definition at line 204 of file selector.cpp.

References endl(), logger, suggestions, and Utility::toInt().

Referenced by Selector().

Here is the call graph for this function:

Here is the caller graph for this function:

void Selector::thresholdFilter ( std::vector< std::string > &  v  )  [private]

Filters out suggestions that could save fewer than THRESHOLD keystrokes.

Assuming prefix.size() == n, suggestion.size() == m, and THRESHOLD == t, then this filter removes those suggestions for which the following condition is true: (m - n) < t

Definition at line 170 of file selector.cpp.

References contextTracker, endl(), ContextTracker::getPrefix(), greedy_suggestion_threshold, and logger.

Referenced by select().

Here is the call graph for this function:

Here is the caller graph for this function:

void Selector::update ( const Observable variable  )  [virtual]

Implements Observer.

Definition at line 261 of file selector.cpp.

References Dispatcher< class_t >::dispatch(), dispatcher, endl(), Observable::get_name(), and logger.

Here is the call graph for this function:

void Selector::update (  ) 

Trigger update of the suggested tokens cache

Definition at line 97 of file selector.cpp.

References clearSuggestedWords(), ContextTracker::contextChange(), and contextTracker.

Here is the call graph for this function:

void Selector::updateSuggestedWords ( const std::vector< std::string > &  v  )  [private]

Adds suggestions to the set of previously selected suggestions.

Definition at line 109 of file selector.cpp.

References endl(), logger, and suggestedWords.

Referenced by select().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 125 of file selector.h.

Referenced by Selector().

Definition at line 124 of file selector.h.

Referenced by select(), Selector(), thresholdFilter(), and update().

std::map<std::string, mbr_func_ptr_t> Selector::dispatch_map [private]

Definition at line 108 of file selector.h.

Definition at line 128 of file selector.h.

Referenced by Selector(), and update().

const char * Selector::GREEDY_SUGGESTION_THRESHOLD = "Presage.Selector.GREEDY_SUGGESTION_THRESHOLD" [static]

Definition at line 101 of file selector.h.

Referenced by Selector().

Logger<char> Selector::logger [private]
const char * Selector::LOGGER = "Presage.Selector.LOGGER" [static]

Definition at line 98 of file selector.h.

Referenced by Selector().

std::string Selector::previous_prefix [private]

Definition at line 122 of file selector.h.

Referenced by Selector().

Definition at line 111 of file selector.h.

Referenced by get_repeat_suggestions(), select(), and set_repeat_suggestions().

const char * Selector::REPEAT_SUGGESTIONS = "Presage.Selector.REPEAT_SUGGESTIONS" [static]

Definition at line 100 of file selector.h.

Referenced by Selector().

Definition at line 120 of file selector.h.

Referenced by clearSuggestedWords(), repetitionFilter(), and updateSuggestedWords().

size_t Selector::suggestions [private]

Definition at line 110 of file selector.h.

Referenced by get_suggestions(), select(), and set_suggestions().

const char * Selector::SUGGESTIONS = "Presage.Selector.SUGGESTIONS" [static]

Definition at line 99 of file selector.h.

Referenced by Selector().


The documentation for this class was generated from the following files:

Generated on 9 Feb 2015 for presage by  doxygen 1.6.1