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 // InferenceNetwork 00015 // 00016 // 24 February 2004 -- tds 00017 // 00018 00019 #ifndef INDRI_INFERENCENETWORK_HPP 00020 #define INDRI_INFERENCENETWORK_HPP 00021 00022 #include "indri/BeliefNode.hpp" 00023 #include "indri/EvaluatorNode.hpp" 00024 #include "indri/ListIteratorNode.hpp" 00025 #include "indri/TermScoreFunction.hpp" 00026 #include "indri/Repository.hpp" 00027 #include "indri/FieldListIterator.hpp" 00028 #include "indri/DocListFrequencyIterator.hpp" 00029 00030 class InferenceNetwork { 00031 public: 00032 typedef std::map< std::string, EvaluatorNode::MResults > MAllResults; 00033 00034 // 00035 // MAllResults stores results indexed first by node name, then second by the node's 00036 // result name. For instance, to retrieve occurrence counts from a 00037 // ContextCountAccumulator named "bd45a", you'd type 'results["bd45a"]["occurrences"]'. 00038 // 00039 00040 private: 00041 std::vector<class indri::index::FieldListIterator*> _fieldIterators; 00042 std::vector<class DocPositionInfoList*> _docIterators; 00043 std::vector<class indri::index::DocListFrequencyIterator*> _freqIterators; 00044 std::vector<ListIteratorNode*> _listIteratorNodes; 00045 std::vector<BeliefNode*> _beliefNodes; 00046 std::vector<EvaluatorNode*> _evaluators; 00047 std::vector<EvaluatorNode*> _complexEvaluators; 00048 std::vector<TermScoreFunction*> _scoreFunctions; 00049 Repository& _repository; 00050 MAllResults _results; 00051 00052 void _moveToDocument( int candidate ); 00053 int _nextCandidateDocument(); 00054 void _evaluateDocument( int document ); 00055 00056 public: 00057 InferenceNetwork( Repository& repository ); 00058 ~InferenceNetwork(); 00059 00060 const std::vector<EvaluatorNode*>& getEvaluators() const; 00061 const EvaluatorNode* getFirstEvaluator() const; 00062 00063 void addDocIterator( DocPositionInfoList* posInfoList ); 00064 void addFieldIterator( indri::index::FieldListIterator* fieldIterator ); 00065 void addFrequencyIterator( indri::index::DocListFrequencyIterator* frequencyIterator ); 00066 void addListNode( ListIteratorNode* listNode ); 00067 void addBeliefNode( BeliefNode* beliefNode ); 00068 void addEvaluatorNode( EvaluatorNode* evaluatorNode ); 00069 void addComplexEvaluatorNode( EvaluatorNode* complexEvaluator ); 00070 void addScoreFunction( TermScoreFunction* scoreFunction ); 00071 const MAllResults& evaluate(); 00072 }; 00073 00074 #endif // INDRI_INFERENCENETWORK_HPP 00075