00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef INDRI_WEIGHTEDANDNODE_HPP
00020 #define INDRI_WEIGHTEDANDNODE_HPP
00021
00022 #include <vector>
00023 #include "indri/BeliefNode.hpp"
00024 #include "indri/SkippingCapableNode.hpp"
00025 #include "indri/ScoredExtentResult.hpp"
00026 #include <math.h>
00027
00028 class WeightedAndNode : public SkippingCapableNode {
00029 private:
00030 struct child_type {
00031 struct maxscore_less {
00032 public:
00033 bool operator () ( const child_type& one, const child_type& two ) const {
00034
00035
00036
00037
00038 return (one.backgroundWeightedScore + two.maximumWeightedScore) >
00039 (one.maximumWeightedScore + two.backgroundWeightedScore);
00040 }
00041 };
00042
00043 BeliefNode* node;
00044 double weight;
00045 double maximumWeightedScore;
00046 double backgroundWeightedScore;
00047 };
00048
00049 std::vector<child_type> _children;
00050 greedy_vector<ScoredExtentResult> _scores;
00051 std::string _name;
00052
00053 double _threshold;
00054 double _recomputeThreshold;
00055 int _quorumIndex;
00056 void _computeQuorum();
00057 double _computeMaxScore( unsigned int start );
00058
00059 public:
00060 WeightedAndNode( const std::string& name ) : _name(name), _threshold(-DBL_MAX), _quorumIndex(0), _recomputeThreshold(-DBL_MAX) {}
00061
00062 void addChild( double weight, BeliefNode* node );
00063
00064
00065 void setThreshold( double threshold );
00066
00067
00068 int nextCandidateDocument();
00069 double maximumScore();
00070 double maximumBackgroundScore();
00071 greedy_vector<ScoredExtentResult>& score( int documentID, int begin, int end, int documentLength );
00072 void annotate( class Annotator& annotator, int documentID, int begin, int end );
00073 bool hasMatch( int documentID );
00074 const std::string& getName() const;
00075 };
00076
00077 #endif // INDRI_WEIGHTEDANDNODE_HPP
00078