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 // RawScorerNodeExtractor.hpp 00015 // 00016 // 5 March 2004 -- tds 00017 // 00018 00019 #ifndef INDRI_RAWSCORERNODEEXTRACTOR_HPP 00020 #define INDRI_RAWSCORERNODEEXTRACTOR_HPP 00021 00022 #include "indri/Walker.hpp" 00023 #include "indri/QuerySpec.hpp" 00024 namespace indri 00025 { 00026 namespace lang 00027 { 00028 00029 class RawScorerNodeExtractor : public indri::lang::Walker { 00030 private: 00031 std::vector<indri::lang::RawScorerNode*> _scorerNodes; 00032 std::vector<indri::lang::Node*> _reachableNodes; 00033 int _insideCount; // used unitialized 00034 00035 public: 00036 RawScorerNodeExtractor() : _insideCount(0) { } 00037 00038 void defaultBefore( indri::lang::Node* n ) { 00039 if( _insideCount ) { 00040 _reachableNodes.push_back(n); 00041 } 00042 } 00043 00044 void before( indri::lang::RawScorerNode* node ) { 00045 _insideCount++; 00046 _scorerNodes.push_back(node); 00047 _reachableNodes.push_back(node); 00048 } 00049 00050 void after( indri::lang::RawScorerNode* node ) { 00051 _insideCount--; 00052 } 00053 00054 void before( indri::lang::NestedRawScorerNode* node ) { 00055 before( (indri::lang::RawScorerNode *) node ); 00056 } 00057 00058 void after( indri::lang::NestedRawScorerNode* node ) { 00059 after( (indri::lang::RawScorerNode *) node ); 00060 } 00061 00062 void before( indri::lang::ShrinkageScorerNode* node ) { 00063 before( (indri::lang::RawScorerNode *) node ); 00064 } 00065 00066 void after( indri::lang::ShrinkageScorerNode* node ) { 00067 after( (indri::lang::RawScorerNode *) node ); 00068 } 00069 00070 std::vector<indri::lang::RawScorerNode*>& getScorerNodes() { 00071 return _scorerNodes; 00072 } 00073 00074 std::vector<indri::lang::Node*>& getReachableNodes() { 00075 return _reachableNodes; 00076 } 00077 }; 00078 } 00079 } 00080 00081 #endif // INDRI_RAWSCORERNODEEXTRACTOR_HPP 00082