26 #include "../utility.h" 27 #include "../predictorRegistry.h" 28 #include "../tokenizer/forwardTokenizer.h" 45 separatorChars (tChars),
46 blankspaceChars(bChars),
47 controlChars (cChars),
48 predictorRegistry (registry),
49 logger (
"ContextTracker", std::cerr),
51 lowercase_mode (true),
94 logger << INFO <<
"SLIDING_WINDOWS_SIZE: " << value <<
endl;
100 logger << INFO <<
"LOWERCASE_MODE: " << value <<
endl;
106 logger << INFO <<
"ONLINE_LEARNING: " << value <<
endl;
142 logger << INFO <<
"learn(): text: " << text <<
endl;
144 std::stringstream stream_to_learn(text);
147 std::vector<std::string> tokens;
152 logger << INFO <<
"learn(): tokenized change: ";
155 tokens.push_back(token);
156 logger << INFO << token <<
'|';
160 if (! tokens.empty()) {
165 if ((
logger << INFO).shouldLog())
167 logger <<
"learn(): sanitized change: ";
168 for (std::vector<std::string>::const_iterator it = tokens.begin();
181 predictor = it.
next();
182 predictor->
learn(tokens);
199 while (tokenizer.hasMoreTokens() && i <= index) {
200 token = tokenizer.nextToken();
257 return getToken(index + change.size());
277 if (completion.find(prefix) == 0) {
286 if(
wordChars.find(c, 0) != std::string::npos)
343 logger << DEBUG <<
"Notification received: " const PresageCallback * context_tracker_callback
std::string blankspaceChars
static const char * LOGGER
ContextChangeDetector * contextChangeDetector
std::string change(const std::string &past_stream) const
void learn(const std::string &text) const
Learn from text.
void set_online_learning(const std::string &value)
PredictorRegistry * predictorRegistry
bool isBlankspaceChar(const char) const
void dispatch(const Observable *var)
static const char * ONLINE_LEARNING
std::string toString() const
std::string getControlChars() const
std::string getBlankspaceChars() const
std::string getPastStream() const
void set_lowercase_mode(const std::string &value)
const PresageCallback * callback(const PresageCallback *callback)
bool isControlChar(const char) const
_SetLevel setlevel(std::string __l)
Manipulator for level.
bool context_change(const std::string &past_stream) const
bool isCompletionValid(const std::string &) const
std::string getSeparatorChars() const
virtual bool hasMoreTokens() const
virtual void learn(const std::vector< std::string > &change)=0
void set_sliding_window_size(const std::string &value)
std::string getFutureStream() const
virtual std::string get_past_stream() const =0
ContextTracker(Configuration *config, PredictorRegistry *predictorRegistry, PresageCallback *callback, const char[]=DEFAULT_WORD_CHARS, const char[]=DEFAULT_SEPARATOR_CHARS, const char[]=DEFAULT_BLANKSPACE_CHARS, const char[]=DEFAULT_CONTROL_CHARS)
void setContextTracker(ContextTracker *ct)
void lowercaseMode(const bool)
std::string getExtraTokenToLearn(const int index, const std::vector< std::string > &change) const
virtual std::string get_name() const =0
virtual std::string nextToken()
void map(Observable *var, const mbr_func_ptr_t &ptr)
static char * strtolower(char *)
static const char * SLIDING_WINDOW_SIZE
static const char * LOWERCASE_MODE
Dispatcher< ContextTracker > dispatcher
static bool isYes(const char *)
void set_sliding_window_size(const std::string &str)
bool isWordChar(const char) const
void set_logger(const std::string &value)
std::string separatorChars
virtual std::string get_value() const =0
std::string getPrefix() const
bool isSeparatorChar(const char) const
std::string getWordChars() const
virtual std::string get_future_stream() const =0
void update_sliding_window(const std::string &str)
const Logger< _charT, _Traits > & endl(const Logger< _charT, _Traits > &lgr)
std::string getToken(const int) const