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

ScoredExtentResult.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2004 University of Massachusetts.  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 //
00014 // ScoredExtentResult
00015 //
00016 // 8 March 2004 -- tds
00017 //
00018 
00019 #ifndef INDRI_SCOREDEXTENTRESULT_HPP
00020 #define INDRI_SCOREDEXTENTRESULT_HPP
00021 
00022 #include "lemur-platform.h"
00023 #include "indri/Extent.hpp"
00024 #include "IndexTypes.hpp"
00025 
00026 namespace indri 
00027 {
00028   namespace api 
00029   {
00030     
00031     struct ScoredExtentResult {
00032       struct score_greater {
00033       public:
00034         bool operator() ( const ScoredExtentResult& one, const ScoredExtentResult& two ) const {
00035           if( one.score != two.score )
00036             return one.score > two.score;
00037 
00038           if( one.document != two.document )
00039             return one.document > two.document;
00040 
00041           if ( one.begin != two.begin )
00042             return one.begin > two.begin;
00043 
00044           return one.end > two.end;
00045 
00046         }
00047       };
00048 
00049       ScoredExtentResult() :
00050         score(0),
00051         document(0),
00052         begin(0),
00053         end(0),
00054         number(0),
00055         ordinal(0),
00056         parentOrdinal(0)
00057       {
00058       }
00059 
00060       ScoredExtentResult( UINT64 s, lemur::api::DOCID_T d )
00061         :
00062         score( double(s) ),
00063         document(d),
00064         begin(0),
00065         end(0),
00066         number(0),
00067         ordinal(0),
00068         parentOrdinal(0)
00069       {
00070       }
00071 
00072       ScoredExtentResult( double s, lemur::api::DOCID_T d )
00073         :
00074         score(s),
00075         document(d),
00076         begin(0),
00077         end(0),
00078         number(0),
00079         ordinal(0),
00080         parentOrdinal(0)
00081       {
00082       }
00083 
00084       ScoredExtentResult( double s, lemur::api::DOCID_T d, int b, int e )
00085         :
00086         score(s),
00087         document(d),
00088         begin(b),
00089         end(e),
00090         number(0),
00091         ordinal(0),
00092         parentOrdinal(0)
00093       {
00094       }
00095 
00096       ScoredExtentResult( double s, lemur::api::DOCID_T d, int b, int e, UINT64 n)
00097         :
00098         score(s),
00099         document(d),
00100         begin(b),
00101         end(e),
00102         number(n),
00103         ordinal(0),
00104         parentOrdinal(0)
00105       {
00106       }
00107 
00108       ScoredExtentResult( double s, lemur::api::DOCID_T d, int b, int e, UINT64 n, int o)
00109         :
00110         score(s),
00111         document(d),
00112         begin(b),
00113         end(e),
00114         number(n),
00115         ordinal(o),
00116         parentOrdinal(0)
00117       {
00118       }
00119 
00120       ScoredExtentResult( double s, lemur::api::DOCID_T d, int b, int e, UINT64 n, int o, int p)
00121         :
00122         score(s),
00123         document(d),
00124         begin(b),
00125         end(e),
00126         number(n),
00127         ordinal(o),
00128         parentOrdinal(p)
00129       {
00130       }
00131 
00132       ScoredExtentResult( const ScoredExtentResult& other ) {
00133         score = other.score;
00134         document = other.document;
00135         begin = other.begin;
00136         end = other.end;
00137         number = other.number;
00138         ordinal = other.ordinal;
00139         parentOrdinal = other.parentOrdinal;
00140       }
00141 
00142       ScoredExtentResult( const indri::index::Extent &extent) {
00143         score = extent.weight;
00144         document = 0;
00145         begin = extent.begin;
00146         end = extent.end;
00147         number = extent.number;
00148         ordinal = extent.ordinal;
00149         parentOrdinal = extent.parent;
00150       }
00151 
00152       bool operator< ( const ScoredExtentResult& other ) const {
00153         return score > other.score;
00154       }
00155 
00156       bool operator== ( const ScoredExtentResult& other ) const {
00157         return ( document == other.document && score == other.score
00158                  && begin == other.begin && end == other.end 
00159                  && number == other.number
00160                  && ordinal==other.ordinal && parentOrdinal==other.parentOrdinal );
00161       }
00162 
00163       const ScoredExtentResult &operator=(const ScoredExtentResult& other) {
00164         score = other.score;
00165         document = other.document;
00166         begin = other.begin;
00167         end = other.end;
00168         number = other.number;
00169         ordinal = other.ordinal;
00170         parentOrdinal = other.parentOrdinal;
00171         return *this;
00172       }
00173 
00174       double score;
00175       lemur::api::DOCID_T document;
00176       int begin;
00177       int end;
00178       UINT64 number; 
00179       int ordinal;
00180       int parentOrdinal;
00181     };
00182   }
00183 }
00184 
00185 #endif // INDRI_SCOREDEXTENTRESULT_HPP
00186 

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