presage  0.8.7
dummyPredictor.cpp
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 #include "dummyPredictor.h"
00026 
00027 
00028 DummyPredictor::DummyPredictor(Configuration* config, ContextTracker* ct)
00029     : Predictor(config,
00030                 ct,
00031                 "DummyPredictor",
00032                 "DummyPredictor, a fake predictor",
00033                 "DummyPredictor is a fake predictor.\n"
00034                 "It does not perform any actual computation nor implement any prediction mechanism.\n"
00035                 "It always returns the same sample prediction.\n")
00036 {}
00037 
00038 DummyPredictor::~DummyPredictor()
00039 {}
00040 
00041 Prediction DummyPredictor::predict(const size_t max_partial_predictions_size, const char** filter) const
00042 {
00043     // A real predictor would query its resources to retrieve the most 
00044     // probable completion of the prefix based on the current history,
00045     // but this is just a dummy predictor that returns random suggestions.
00046     //
00047     Prediction result;
00048 
00049     result.addSuggestion (Suggestion("foo1", 0.99));
00050     result.addSuggestion (Suggestion("foo2", 0.98));
00051     result.addSuggestion (Suggestion("foo3", 0.97));
00052     result.addSuggestion (Suggestion("foo4", 0.96));
00053     result.addSuggestion (Suggestion("foo5", 0.95));
00054     result.addSuggestion (Suggestion("foo6", 0.94));
00055 
00056     result.addSuggestion (Suggestion("bar1", 0.89));
00057     result.addSuggestion (Suggestion("bar2", 0.88));
00058     result.addSuggestion (Suggestion("bar3", 0.87));
00059     result.addSuggestion (Suggestion("bar4", 0.86));
00060     result.addSuggestion (Suggestion("bar5", 0.85));
00061     result.addSuggestion (Suggestion("bar6", 0.84));
00062 
00063     result.addSuggestion (Suggestion("foobar1", 0.79));
00064     result.addSuggestion (Suggestion("foobar2", 0.78));
00065     result.addSuggestion (Suggestion("foobar3", 0.77));
00066     result.addSuggestion (Suggestion("foobar4", 0.76));
00067     result.addSuggestion (Suggestion("foobar5", 0.75));
00068     result.addSuggestion (Suggestion("foobar6", 0.74));
00069 
00070     return result;
00071 }
00072 
00073 void DummyPredictor::learn(const std::vector<std::string>& change)
00074 {
00075     std::cout << "DummyPredictor::learn() method called" << std::endl;
00076     std::cout << "DummyPredictor::learn() method exited" << std::endl;
00077 }