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 // ContextCountGraphCopier 00015 // 00016 // 5 March 2004 -- tds 00017 // 00018 00019 #ifndef INDRI_CONTEXTCOUNTGRAPHCOPIER_HPP 00020 #define INDRI_CONTEXTCOUNTGRAPHCOPIER_HPP 00021 00022 class ContextCountGraphCopier : public indri::lang::Copier { 00023 private: 00024 std::vector<indri::lang::Node*> _newNodes; 00025 std::vector<indri::lang::ContextCounterNode*> _contextCounters; 00026 00027 public: 00028 indri::lang::Node* defaultAfter( indri::lang::Node* oldNode, indri::lang::Node* newNode ) { 00029 _newNodes.push_back( newNode ); 00030 return newNode; 00031 } 00032 00033 indri::lang::Node* after( indri::lang::RawScorerNode* oldNode, indri::lang::RawScorerNode* newNode ) { 00034 indri::lang::RawExtentNode* raw = newNode->getRawExtent(); 00035 indri::lang::RawExtentNode* context = newNode->getContext(); 00036 delete newNode; 00037 00038 indri::lang::ContextCounterNode* contextCounter = new indri::lang::ContextCounterNode( raw, context ); 00039 // need to match the name of the raw scorer we're counting for 00040 contextCounter->setNodeName( oldNode->nodeName() ); 00041 _newNodes.push_back( contextCounter ); 00042 _contextCounters.push_back( contextCounter ); 00043 return contextCounter; 00044 } 00045 00046 std::vector<indri::lang::Node*>& getNodes() { 00047 return _newNodes; 00048 } 00049 00050 std::vector<indri::lang::ContextCounterNode*>& getContextCounterNodes() { 00051 return _contextCounters; 00052 } 00053 }; 00054 00055 #endif // INDRI_CONTEXTCOUNTGRAPHCOPIER_HPP 00056