presage  0.9.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Simulator Class Reference

#include <simulator.h>

Collaboration diagram for Simulator:
Collaboration graph

Public Member Functions

 Simulator (PresageCallback *callback, std::stringstream &sstream, const std::string="")
 
 ~Simulator ()
 
void simulate (std::string)
 
void results () const
 
int getKi () const
 
int getKs () const
 
int getKn () const
 
double getKSR () const
 
bool getAutoSpace () const
 
void setAutoSpace (bool)
 
void setKs (int)
 
void silentMode (bool)
 

Private Member Functions

bool find (const std::vector< std::string > &, const std::string &) const
 

Private Attributes

PresagepresagePtr
 
bool autoSpace
 
int ki
 
int ks
 
int kn
 
bool silent_mode
 
std::stringstream & m_sstream
 

Detailed Description

Evaluates how good Presage is at doing its job (in other words, its ability to reduce keystrokes the user is required to type).

Simulator computes the KSR (Keystrokes Savings Rate) obtained by using Presage preditive ability compared to manually entering text.

The KSR is computed as ( 1 - ( ki + ks ) / kn ) * 100, where ki is the number of input characters actually typed ks is the number of keystrokes needed to select among the predictions presented kn is the number of keystrokes that would be needed if the whole text was typed without any prediction aid.

The simulator is built with a reference to a Presage object which simulates and takes a string holding the text to be run through the simulation. Multiple calls to the simulate method can take place. Each call runs the string through the simulator. The results of each simulate call update the internal state of the simulator object. The results of the simulation can be retrieved at any time by invoking the results method or the get methods.

Definition at line 51 of file simulator.h.

Constructor & Destructor Documentation

◆ Simulator()

Simulator::Simulator ( PresageCallback callback,
std::stringstream &  sstream,
const std::string  config = "" 
)

Definition at line 28 of file simulator.cpp.

References autoSpace, config, ki, kn, ks, presagePtr, and silent_mode.

◆ ~Simulator()

Simulator::~Simulator ( )

Definition at line 45 of file simulator.cpp.

References presagePtr.

Member Function Documentation

◆ find()

bool Simulator::find ( const std::vector< std::string > &  w,
const std::string &  t 
) const
private

Definition at line 215 of file simulator.cpp.

References endl(), Presage::prefix(), presagePtr, and silent_mode.

Referenced by simulate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAutoSpace()

bool Simulator::getAutoSpace ( ) const

Definition at line 235 of file simulator.cpp.

References autoSpace.

◆ getKi()

int Simulator::getKi ( ) const

Definition at line 184 of file simulator.cpp.

References ki.

◆ getKn()

int Simulator::getKn ( ) const

Definition at line 196 of file simulator.cpp.

References kn.

◆ getKs()

int Simulator::getKs ( ) const

Definition at line 190 of file simulator.cpp.

References ks.

◆ getKSR()

double Simulator::getKSR ( ) const

Definition at line 202 of file simulator.cpp.

References ki, kn, and ks.

Referenced by results().

Here is the caller graph for this function:

◆ results()

void Simulator::results ( ) const

Definition at line 163 of file simulator.cpp.

References endl(), getKSR(), ki, kn, and ks.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAutoSpace()

void Simulator::setAutoSpace ( bool  b)

Definition at line 240 of file simulator.cpp.

References autoSpace.

◆ setKs()

void Simulator::setKs ( int  value)

Definition at line 208 of file simulator.cpp.

References ks.

◆ silentMode()

void Simulator::silentMode ( bool  mode)

Definition at line 245 of file simulator.cpp.

References silent_mode.

Referenced by main().

Here is the caller graph for this function:

◆ simulate()

void Simulator::simulate ( std::string  str)

Definition at line 51 of file simulator.cpp.

References autoSpace, find(), ki, kn, ks, m_sstream, Presage::predict(), and presagePtr.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ autoSpace

bool Simulator::autoSpace
private

Definition at line 97 of file simulator.h.

Referenced by getAutoSpace(), setAutoSpace(), simulate(), and Simulator().

◆ ki

int Simulator::ki
private

Definition at line 99 of file simulator.h.

Referenced by getKi(), getKSR(), results(), simulate(), and Simulator().

◆ kn

int Simulator::kn
private

Definition at line 101 of file simulator.h.

Referenced by getKn(), getKSR(), results(), simulate(), and Simulator().

◆ ks

int Simulator::ks
private

Definition at line 100 of file simulator.h.

Referenced by getKs(), getKSR(), results(), setKs(), simulate(), and Simulator().

◆ m_sstream

std::stringstream& Simulator::m_sstream
private

Definition at line 105 of file simulator.h.

Referenced by simulate().

◆ presagePtr

Presage* Simulator::presagePtr
private

Definition at line 93 of file simulator.h.

Referenced by find(), simulate(), Simulator(), and ~Simulator().

◆ silent_mode

bool Simulator::silent_mode
private

Definition at line 103 of file simulator.h.

Referenced by find(), silentMode(), and Simulator().


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