Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TreePrinterWalker.hpp

Go to the documentation of this file.
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 // TreePrinterWalker
00015 //
00016 // 9 March 2004 -- tds
00017 //
00018 
00019 #ifndef INDRI_TREEPRINTERWALKER_HPP
00020 #define INDRI_TREEPRINTERWALKER_HPP
00021 
00022 #include "indri/QuerySpec.hpp"
00023 
00024 class TreePrinterWalker : public indri::lang::Walker {
00025 private:
00026   unsigned int _tabs;
00027 public:
00028   TreePrinterWalker() : _tabs(0) {}
00029 
00030   void before( indri::lang::IndexTerm* node ) {
00031     for( unsigned int i=0; i<_tabs; i++ )
00032       std::cout << "\t";
00033 
00034     std::cout << "IndexTerm "
00035               << node->getText().c_str()
00036               << " "
00037               << node->nodeName().c_str()
00038               << std::endl;
00039 
00040     _tabs++;
00041   }
00042 
00043   void before( indri::lang::Field* node ) {
00044     for( unsigned int i=0; i<_tabs; i++ )
00045       std::cout << "\t";
00046 
00047     std::cout << "Field "
00048               << node->getFieldName().c_str()
00049               << " "
00050               << node->nodeName().c_str()
00051               << std::endl;
00052 
00053     _tabs++;
00054   }
00055 
00056   void defaultBefore( indri::lang::Node* node ) {
00057     for( unsigned int i=0; i<_tabs; i++ )
00058       std::cout << "\t";
00059 
00060     std::string type = node->typeName();
00061     std::string query = node->queryText();
00062 
00063     std::cout << type
00064               << " "
00065               << query
00066               << std::endl;
00067 
00068     _tabs++;
00069   }
00070 
00071   void defaultAfter( indri::lang::Node* node ) {
00072     _tabs--;
00073   }
00074 };
00075 
00076 #endif // INDRI_TREEPRINTERWALKER_HPP
00077 
00078 

Generated on Wed Nov 3 12:59:06 2004 for Lemur Toolkit by doxygen1.2.18