Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FilterNode.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 // FilterNode
00015 //
00016 // 21 July 2004 -- tds
00017 //
00018 // Restricts evaluation to only a subset of the documents
00019 // in the collection.
00020 //
00021 
00022 #ifndef INDRI_FILTERNODE_HPP
00023 #define INDRI_FILTERNODE_HPP
00024 
00025 class FilterNode : public BeliefNode {
00026 private:
00027   BeliefNode* _belief;
00028   std::vector<int> _documents;
00029   std::string _name;
00030   int _index;
00031 
00032 public:
00033   FilterNode( const std::string& name, BeliefNode* child, const std::vector<int>& documents )
00034     :
00035     _documents(documents)
00036   {
00037     _name = name;
00038     _belief = child;
00039     _index = 0;
00040     std::sort( _documents.begin(), _documents.end() );
00041   }
00042 
00043   int nextCandidateDocument() {
00044     int childNext = _belief->nextCandidateDocument();
00045 
00046     while( _index < _documents.size() && _documents[_index] < childNext )
00047       _index++;
00048     
00049     if( _index == _documents.size() )
00050       return MAX_INT32;
00051 
00052     return _documents[_index];
00053   }
00054 
00055   void annotate( Annotator& annotator, int documentID, int begin, int end ) {
00056     return _belief->annotate( annotator, documentID, begin, end );
00057   }
00058 
00059   const greedy_vector<ScoredExtentResult>& score( int documentID, int begin, int end, int documentLength ) {
00060     return _belief->score( documentID, begin, end, documentLength );
00061   }
00062 
00063   double maximumScore() {
00064     return _belief->maximumScore();
00065   }
00066 
00067   double maximumBackgroundScore() {
00068     return _belief->maximumBackgroundScore();
00069   }
00070 
00071   bool hasMatch( int documentID ) {
00072     return _belief->hasMatch( documentID );
00073   }
00074 
00075   const std::string& getName() const {
00076     return _name;
00077   }
00078 };
00079 
00080 #endif // INDRI_FILTERNODE_HPP
00081 

Generated on Wed Nov 3 12:58:55 2004 for Lemur Toolkit by doxygen1.2.18