Simulator Class Reference

`#include <simulator.h>`

Collaboration diagram for Simulator:

## 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

Presage * | presagePtr
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 52 of file simulator.h.

## Constructor & Destructor Documentation

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

Definition at line 29 of file simulator.cpp.

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

Simulator::~Simulator | ( |  | ) |

Definition at line 46 of file simulator.cpp.

References presagePtr.

## Member Function Documentation

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

private

Definition at line 216 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:

bool Simulator::getAutoSpace | ( |  | ) | const

Definition at line 236 of file simulator.cpp.

References autoSpace.

int Simulator::getKi | ( |  | ) | const

Definition at line 185 of file simulator.cpp.

References ki.

int Simulator::getKn | ( |  | ) | const

Definition at line 197 of file simulator.cpp.

References kn.

int Simulator::getKs | ( |  | ) | const

Definition at line 191 of file simulator.cpp.

References ks.

double Simulator::getKSR | ( |  | ) | const

Definition at line 203 of file simulator.cpp.

References ki, kn, and ks.

Referenced by results().

Here is the caller graph for this function:

void Simulator::results | ( |  | ) | const

Definition at line 164 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:

void Simulator::setAutoSpace | ( | bool | b | ) |

Definition at line 241 of file simulator.cpp.

References autoSpace.

void Simulator::setKs | ( | int | value | ) |

Definition at line 209 of file simulator.cpp.

References ks.

void Simulator::silentMode | ( | bool | mode | ) |

Definition at line 246 of file simulator.cpp.

References silent_mode.

Referenced by main().

Here is the caller graph for this function:

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

Definition at line 52 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

bool Simulator::autoSpace

private

Definition at line 79 of file simulator.h.

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

int Simulator::ki

private

Definition at line 81 of file simulator.h.

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

int Simulator::kn

private

Definition at line 83 of file simulator.h.

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

int Simulator::ks

private

Definition at line 82 of file simulator.h.

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

std::stringstream& Simulator::m_sstream

private

Definition at line 87 of file simulator.h.

Referenced by simulate().

Presage* Simulator::presagePtr

private

Definition at line 75 of file simulator.h.

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

bool Simulator::silent_mode

private

Definition at line 85 of file simulator.h.

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

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

- /build/buildd/presage-0.8.8/src/tools/simulator/simulator.h
- /build/buildd/presage-0.8.8/src/tools/simulator/simulator.cpp