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 // OrNode 00015 // 00016 // 31 March 2004 -- tds 00017 // 00018 // Implements the InQuery #or node. 00019 // 00020 // Note that this class transforms the probabilities 00021 // out of log space and back into log space, which 00022 // could cause a (catastrophic) loss of precision. 00023 // 00024 00025 #ifndef INDRI_ORNODE_HPP 00026 #define INDRI_ORNODE_HPP 00027 00028 #include <math.h> 00029 #include "indri/BeliefNode.hpp" 00030 #include <vector> 00031 #include "indri/greedy_vector" 00032 namespace indri 00033 { 00034 namespace infnet 00035 { 00036 00037 class OrNode : public BeliefNode { 00038 private: 00039 std::vector<BeliefNode*> _children; 00040 indri::utility::greedy_vector<indri::api::ScoredExtentResult> _scores; 00041 indri::utility::greedy_vector<bool> _matches; 00042 std::string _name; 00043 00044 public: 00045 OrNode( const std::string& name ); 00046 OrNode( const std::string& name, const std::vector<BeliefNode*>& children ); 00047 00048 const indri::utility::greedy_vector<indri::api::ScoredExtentResult>& score( lemur::api::DOCID_T documentID, indri::index::Extent &extent, int documentLength ); 00049 void annotate( class Annotator& annotator, lemur::api::DOCID_T documentID, indri::index::Extent &extent ); 00050 double maximumScore(); 00051 double maximumBackgroundScore(); 00052 00053 bool hasMatch( lemur::api::DOCID_T documentID ); 00054 const indri::utility::greedy_vector<bool>& hasMatch( lemur::api::DOCID_T documentID, const indri::utility::greedy_vector<indri::index::Extent>& extents ); 00055 lemur::api::DOCID_T nextCandidateDocument(); 00056 void indexChanged( indri::index::Index& index ); 00057 00058 virtual void setSiblingsFlag(int f); 00059 00060 const std::string& getName() const; 00061 }; 00062 } 00063 } 00064 00065 #endif // INDRI_ORNODE_HPP 00066