LCOV - lcov.info - ept/popcon/local.h

LTP GCOV extension - code coverage report
Current view: | directory - ept/popcon - local.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 1
Code covered: | 100.0 % |  | Executed lines: | 1

           1                 : #ifndef EPT_POPCON_LOCAL_H
           2                 : #define EPT_POPCON_LOCAL_H
           3                 :
           4                 : /** @file
           5                 :  * @author Enrico Zini <enrico@enricozini.org>
           6                 :  * Correlate popcon data with local popcon information
           7                 :  */
           8                 :
           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                 :
          36                 : /**
          37                 :  * Access the results of the local daily popcon scan.
          38                 :  */
          39                 : class Local
          40               1 : {
          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                 :
          48                 :         /// Get the timestamp of the local popcon information
          49                 :         time_t timestamp() const { return m_timestamp; }
          50                 :
          51                 :         /// Return true if this data source has data, false if it's empty
          52                 :         bool hasData() const { return m_timestamp != 0; }
          53                 :
          54                 :         /**
          55                 :          * Return the local score of the package
          56                 :          */
          57                 :         float score(const std::string& pkg) const;
          58                 :
          59                 :         /**
          60                 :          * Return the TFIDF score of the package computed against the popcon
          61                 :          * information.
          62                 :          *
          63                 :          * The TFIDF score is high when a package is representative of this system,
          64                 :          * that is, it is used in this system and not much used in other systems.
          65                 :          */
          66                 :         float tfidf(const Popcon& popcon, const std::string& pkg) const;
          67                 :
          68                 :         /**
          69                 :          * Read the local popcon vote and return the list of packages and their
          70                 :          * local scores, sorted by ascending score.
          71                 :          */
          72                 :         std::vector< std::pair<std::string, float> > scores() const;
          73                 :
          74                 :         /**
          75                 :          * Read the local popcon vote and return the list of packages and their
          76                 :          * TFIDF scores computed against the popcon information.
          77                 :          *
          78                 :          * The packages will be sorted by ascending score.
          79                 :          */
          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

Generated by: LTP GCOV extension version 1.6