Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound 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.cs.cmu.edu/~lemur/license.html
00008  *
00009  *==========================================================================
00010 */
00011 
00012 
00013 #ifndef _DOCSCORE_HPP
00014 #define _DOCSCORE_HPP
00015 
00017 
00025 #include "common_headers.hpp"
00026 #include <algorithm>
00027 
00028 struct DocScore {
00029   const char* id;
00030   double val;
00031 };
00032 
00033 
00034 class DocScoreVector : public vector<DocScore> {
00035 public:
00036   
00037   DocScoreVector() : vector<DocScore>() {}
00038   DocScoreVector(int size) : vector<DocScore>(size) {}
00039   virtual ~DocScoreVector() {}
00040 
00042   virtual void PushValue(const char* docid, double value);
00043 
00045   virtual void Sort(bool descending = true);
00046 private:
00047 
00050 
00051   class ScoreAscending {
00052   public:
00053     bool operator()(const DocScore & a, const DocScore & b) {
00054       return a.val < b.val;  // based on the real value
00055     }
00056   };
00057 
00058   class ScoreDescending { 
00059   public: 
00060     bool operator()(const DocScore & a, const DocScore & b) {
00061       return a.val > b.val;  // based on the real value
00062     }
00063   };
00064 
00065   static ScoreAscending ascendOrder;
00066   static ScoreDescending descendOrder;
00067 
00068 };
00069 
00070 
00071 
00072 #endif 
00073 
00074 
00075   
00076 
00077 

Generated on Mon Sep 30 14:13:20 2002 for LEMUR by doxygen1.2.18