"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2b/scorer.h" (12 Feb 2021, 1014 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "scorer.h" see the Fossies "Dox" file reference documentation.

    1 /***************************************************************************
    2  *   Copyright (C) 2004-2021 by Pere Constans
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *   See the LICENSE file that comes with this distribution.
    6  ***************************************************************************/
    7 #ifndef SCORER_H
    8 #define SCORER_H
    9 
   10 #include <QList>
   11 
   12 #ifdef C2B_DEBUG_SEARCHING
   13 #include <QtDebug>
   14 #endif
   15 
   16 struct scorer
   17 {
   18     scorer() : tscore(0), nscores(0) {}
   19 
   20     void initialize()
   21     {
   22         tscore = double(0);
   23         nscores = 0;
   24     }
   25     void update(const int plength, const int length)
   26     {
   27         const double s(plength == 0 ? double(1) : double(1) / (double(1) + std::abs(length - plength)));
   28         tscore += s;
   29         ++nscores;
   30     }
   31     double score() const
   32     {
   33 #ifdef C2B_DEBUG_SEARCHING
   34         qDebug() << "scorer: n score" << nscores << tscore;
   35 #endif
   36         return tscore;
   37     }
   38 
   39     double tscore;
   40     int nscores;
   41 };
   42 
   43 #endif