presage
0.8.7
|
00001 00002 /****************************************************** 00003 * Presage, an extensible predictive text entry system 00004 * --------------------------------------------------- 00005 * 00006 * Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk> 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License along 00019 with this program; if not, write to the Free Software Foundation, Inc., 00020 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00021 * 00022 **********(*)*/ 00023 00024 00025 #ifndef PRESAGE_RECENCYPREDICTOR 00026 #define PRESAGE_RECENCYPREDICTOR 00027 00028 #include "predictor.h" 00029 #include "../core/logger.h" 00030 #include "../core/dispatcher.h" 00031 00064 class RecencyPredictor : public Predictor, public Observer { 00065 public: 00066 RecencyPredictor(Configuration*, ContextTracker*); 00067 ~RecencyPredictor(); 00068 00069 virtual Prediction predict(const size_t size, const char** filter) const; 00070 00071 virtual void learn(const std::vector<std::string>& change); 00072 00073 virtual void update (const Observable* variable); 00074 00075 private: 00076 void set_lambda (const std::string& value); 00077 void set_n_0 (const std::string& value); 00078 void set_cutoff_threshold (const std::string& value); 00079 00080 static const char* LOGGER; 00081 static const char* LAMBDA; 00082 static const char* N_0; 00083 static const char* CUTOFF_THRESHOLD; 00084 00085 double lambda; 00086 double n_0; 00087 size_t cutoff_threshold; 00088 00089 Dispatcher<RecencyPredictor> dispatcher; 00090 00091 }; 00092 00093 #endif // PRESAGE_RECENCYPREDICTOR