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_CONTEXTCHANGEDETECTOR 00026 #define PRESAGE_CONTEXTCHANGEDETECTOR 00027 00028 #ifdef HAVE_CONFIG_H 00029 #include "config.h" 00030 #endif 00031 00032 #include <string> 00033 00034 #include "../configuration.h" 00035 00036 class ContextChangeDetector { 00037 public: 00038 ContextChangeDetector(const std::string, 00039 const std::string, 00040 const std::string, 00041 const std::string); 00042 ~ContextChangeDetector(); 00043 00044 bool context_change(const std::string& past_stream) const; 00045 std::string change(const std::string& past_stream) const; 00046 00047 std::string get_sliding_window() const; 00048 00049 void set_sliding_window_size(const std::string& str); 00050 void update_sliding_window(const std::string& str); 00051 00052 private: 00053 bool context_change_helper(const std::string& str1, const std::string& str2) const; 00054 00055 static const std::string::size_type DEFAULT_SLIDING_WINDOW_SIZE; 00056 std::string::size_type SLIDING_WINDOW_SIZE; 00057 std::string sliding_window; 00058 00059 const std::string wordChars; 00060 const std::string separatorChars; 00061 const std::string blankspaceChars; 00062 const std::string controlChars; 00063 00064 }; 00065 00066 #endif // PRESAGE_CONTEXTCHANGEDETECTOR