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

SumNode.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 // SumNode
00015 //
00016 // 3 February 2004 -- tds
00017 //
00018 // True sum of belief inputs (not a weighted or
00019 // normalized sum).
00020 //
00021 
00022 #ifndef INDRI_SUMNODE_HPP
00023 #define INDRI_SUMNODE_HPP
00024 
00025 #include <vector>
00026 #include "lemur-platform.h"
00027 
00028 class SumNode : public BeliefNode {
00029 private:
00030   std::vector<BeliefNode*> _children;
00031   double _threshold;
00032 
00033 public:
00034   void addChild( BeliefNode* beliefNode ) {
00035     _children.push_back( beliefNode );
00036   }
00037 
00038   int nextCandidateDocument() {
00039     std::vector<BeliefNode*>::iterator iter;
00040     int next = MAX_INT32;
00041 
00042     for( iter = _children.begin(); iter != _children.end(); iter++ ) {
00043       next = lemur_compat::min( next, (*iter)->nextCandidateDocument() );
00044     }
00045 
00046     return next;
00047   }
00048 
00049   double maximumScore() {
00050     std::vector<BeliefNode*>::iterator iter;
00051     double score = 0;
00052 
00053     for( iter = _children.begin(); iter != _children.end(); iter++ ) {
00054       score += (*iter)->maximumScore();
00055     }
00056 
00057     return score;
00058   }
00059 
00060   double score( int documentID, int documentLength ) {
00061     std::vector<BeliefNode*>::iterator iter;
00062     double score = 0;
00063 
00064     for( iter = _children.begin(); iter != _children.end(); iter++ ) {
00065       score += (*iter)->score( documentID, documentLength );
00066     }
00067 
00068     return score;
00069   }
00070 };
00071 
00072 #endif // INDRI_SUMNODE_HPP
00073 
00074 

Generated on Wed Nov 3 12:59:04 2004 for Lemur Toolkit by doxygen1.2.18