libept
local.h
Go to the documentation of this file.
00001 #ifndef EPT_POPCON_LOCAL_H
00002 #define EPT_POPCON_LOCAL_H
00003 
00009 /*
00010  * Copyright (C) 2007  Enrico Zini <enrico@debian.org>
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  */
00026 
00027 #include <string>
00028 #include <vector>
00029 #include <map>
00030 
00031 namespace ept {
00032 namespace popcon {
00033 
00034 class Popcon;
00035 
00039 class Local
00040 {
00041 protected:
00042     std::map<std::string, float> m_scores;
00043     time_t m_timestamp;
00044 
00045 public:
00046     Local(const std::string& file = std::string("/var/log/popularity-contest"));
00047 
00049     time_t timestamp() const { return m_timestamp; }
00050 
00052     bool hasData() const { return m_timestamp != 0; }
00053 
00057     float score(const std::string& pkg) const;
00058 
00066     float tfidf(const Popcon& popcon, const std::string& pkg) const;
00067 
00072     std::vector< std::pair<std::string, float> > scores() const;
00073 
00080     std::vector< std::pair<std::string, float> > tfidf(const Popcon& popcon) const;
00081 };
00082 
00083 }
00084 }
00085 
00086 // vim:set ts=4 sw=4:
00087 #endif