libept
local.h
Go to the documentation of this file.
1 #ifndef EPT_POPCON_LOCAL_H
2 #define EPT_POPCON_LOCAL_H
3 
9 /*
10  * Copyright (C) 2007 Enrico Zini <enrico@debian.org>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  */
26 
27 #include <string>
28 #include <vector>
29 #include <map>
30 
31 namespace ept {
32 namespace popcon {
33 
34 class Popcon;
35 
39 class Local
40 {
41 protected:
42  std::map<std::string, float> m_scores;
43  time_t m_timestamp;
44 
45 public:
46  Local(const std::string& file = std::string("/var/log/popularity-contest"));
47 
49  time_t timestamp() const { return m_timestamp; }
50 
52  bool hasData() const { return m_timestamp != 0; }
53 
57  float score(const std::string& pkg) const;
58 
66  float tfidf(const Popcon& popcon, const std::string& pkg) const;
67 
72  std::vector< std::pair<std::string, float> > scores() const;
73 
80  std::vector< std::pair<std::string, float> > tfidf(const Popcon& popcon) const;
81 };
82 
83 }
84 }
85 
86 // vim:set ts=4 sw=4:
87 #endif