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

NumericFieldAnnotator.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2003-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 // NumericFieldAnnotator
00015 //
00016 // 25 May 2004 -- tds
00017 //
00018 
00019 #ifndef INDRI_NUMERICFIELDANNOTATOR_HPP
00020 #define INDRI_NUMERICFIELDANNOTATOR_HPP
00021 
00022 class NumericFieldAnnotator : public Transformation {
00023 private:
00024   ObjectHandler<ParsedDocument>* _handler;
00025   std::string& _field;
00026 
00027 public:
00028   NumericFieldAnnotator( std::string& field ) :
00029     _handler(0),
00030     _field(field)
00031   {
00032   }
00033 
00034   ParsedDocument* transform( ParsedDocument* document ) {
00035     for( size_t i=0; i<document->tags.size(); i++ ) {
00036       TagExtent& extent = document->tags[i];
00037 
00038       if( _field == extent.name ) {
00039         char* numberText = document->terms[ extent.begin ]; 
00040         INT64 value = string_to_i64( numberText );
00041         extent.number = value;
00042       }
00043     }
00044 
00045     return document;
00046   }
00047 
00048   void setHandler( ObjectHandler<ParsedDocument>& handler ) {
00049     _handler = &handler;
00050   }
00051 
00052   void handle( ParsedDocument* document ) {
00053     _handler->handle( transform( document ) );
00054   }
00055 };
00056 
00057 
00058 #endif // INDRI_NUMERICFIELDANNOTATOR_HPP
00059 
00060 

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