presage  0.8.7
suggestion.h
Go to the documentation of this file.
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_SUGGESTION
00026 #define PRESAGE_SUGGESTION
00027 
00028 #ifdef HAVE_CONFIG_H
00029 #include "config.h"
00030 #endif
00031 
00032 #include <iostream>
00033 #include <sstream>
00034 #include <string>
00035 
00036 #include "../presageException.h"
00037 
00050 class Suggestion {
00051     friend std::ostream &operator<<( std::ostream &, const Suggestion & );
00052 public:
00053     Suggestion(std::string="",double=0.0);
00054     ~Suggestion();
00055 
00056     bool operator== (const Suggestion&) const;
00057     bool operator!= (const Suggestion&) const;
00058     bool operator<  (const Suggestion&) const;
00059 
00060     std::string getWord() const;
00061     double getProbability() const;
00062     void setWord(std::string);
00063     void setProbability(double);
00066     std::string toString() const;
00067 
00068     static const double MIN_PROBABILITY;
00069     static const double MAX_PROBABILITY;
00070 
00071     class SuggestionException : public PresageException {
00072     public:
00073         SuggestionException(presage_error_code_t code, const std::string& msg) throw() : PresageException(code, msg) { }
00074         virtual ~SuggestionException() throw() { }
00075 
00076     private:
00077         SuggestionException() throw() : PresageException(PRESAGE_ERROR, "") {};
00078 
00079     };
00080 
00081 private:
00082     std::string word;
00083     double probability;
00084 
00085 };
00086 
00087 
00088 
00089 #endif // PRESAGE_SUGGESTION