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 #include <time.h>
31 
32 namespace ept {
33 namespace popcon {
34 
35 class Popcon;
36 
40 class Local
41 {
42 protected:
43  std::map<std::string, float> m_scores;
44  time_t m_timestamp;
45 
46 public:
47  Local(const std::string& file = std::string("/var/log/popularity-contest"));
48 
50  time_t timestamp() const { return m_timestamp; }
51 
53  bool hasData() const { return m_timestamp != 0; }
54 
58  float score(const std::string& pkg) const;
59 
67  float tfidf(const Popcon& popcon, const std::string& pkg) const;
68 
73  std::vector< std::pair<std::string, float> > scores() const;
74 
81  std::vector< std::pair<std::string, float> > tfidf(const Popcon& popcon) const;
82 };
83 
84 }
85 }
86 
87 // vim:set ts=4 sw=4:
88 #endif
std::map< std::string, float > m_scores
Definition: local.h:43
time_t m_timestamp
Definition: local.h:44
Maps Packages to IDs and vice-versa.
Definition: popcon.h:73
bool hasData() const
Return true if this data source has data, false if it's empty.
Definition: local.h:53
Definition: apt.cc:42
time_t timestamp() const
Get the timestamp of the local popcon information.
Definition: local.h:50
std::vector< std::pair< std::string, float > > scores() const
Read the local popcon vote and return the list of packages and their local scores, sorted by ascending score.
Definition: local.cc:136
Access the results of the local daily popcon scan.
Definition: local.h:40
Local(const std::string &file=std::string("/var/log/popularity-contest"))
Definition: local.cc:75
float tfidf(const Popcon &popcon, const std::string &pkg) const
Return the TFIDF score of the package computed against the popcon information.
Definition: local.cc:125
float score(const std::string &pkg) const
Return the local score of the package.
Definition: local.cc:112