Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

DocScore.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2001 Carnegie Mellon University.  All Rights Reserved.
00003  *
00004  * Use of the Lemur Toolkit for Language Modeling and Information Retrieval
00005  * is subject to the terms of the software license set forth in the LICENSE
00006  * file included with this software, and also available at
00007  * http://www.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010  */
00011 
00012 
00013 #ifndef _DOCSCORE_HPP
00014 #define _DOCSCORE_HPP
00015 
00016 #include "common_headers.hpp"
00017 #include <algorithm>
00018 #include <string>
00019 namespace lemur
00020 {
00021   namespace distrib 
00022   {
00029     struct DocScore {
00030       double val;
00031       string id;
00032     };
00034 
00035     class DocScoreVector : public vector<DocScore> {
00036     public:
00037   
00038       DocScoreVector() : vector<DocScore>() {}
00039       DocScoreVector(int size) : vector<DocScore>(size) {}
00040       virtual ~DocScoreVector();
00041 
00043       virtual void PushValue(const string &docid, double value);
00044 
00046       virtual void Sort(bool descending = true);
00047     private:
00048 
00051 
00052       class ScoreAscending {
00053       public:
00054         bool operator()(const DocScore & a, const DocScore & b) {
00055           return a.val < b.val;  // based on the real value
00056         }
00057       };
00058 
00059       class ScoreDescending { 
00060       public: 
00061         bool operator()(const DocScore & a, const DocScore & b) {
00062           return a.val > b.val;  // based on the real value
00063         }
00064       };
00065 
00066       static ScoreAscending ascendOrder;
00067       static ScoreDescending descendOrder;
00068 
00069     };
00070  
00071   }
00072 }
00073 
00074 
00075 #endif

Generated on Tue Jun 15 11:02:53 2010 for Lemur by doxygen 1.3.4