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 // KrovetzStemmerTransformation.hpp 00015 // 00016 // 13 May 2004 -- tds 00017 // 00018 00019 #ifndef INDRI_KROVETZSTEMMERTRANSFORMATION_HPP 00020 #define INDRI_KROVETZSTEMMERTRANSFORMATION_HPP 00021 00022 #include "indri/Transformation.hpp" 00023 #include "indri/Parameters.hpp" 00024 #include "indri/KrovetzStemmer.hpp" 00025 namespace indri 00026 { 00027 namespace parse 00028 { 00029 00030 class KrovetzStemmerTransformation : public Transformation { 00031 private: 00032 KrovetzStemmer *stemmer; 00033 char* _stemBuffer; 00034 size_t _stemBufferSize; 00035 ObjectHandler<indri::api::ParsedDocument>* _handler; 00036 00037 char* _getBuffer( size_t length ); 00038 const char* _getBufferEnd() const; 00039 indri::api::ParsedDocument* _restart( indri::api::ParsedDocument* document, size_t lastIndex, char* endOfStemming ); 00040 indri::api::ParsedDocument* _processTerms( indri::api::ParsedDocument* document, size_t start, char* stem, const char* end ); 00041 char* _growBuffer( size_t length, char* oldEnd ); 00042 00043 public: 00044 KrovetzStemmerTransformation( indri::api::Parameters& parameters ); 00045 ~KrovetzStemmerTransformation(); 00046 00047 indri::api::ParsedDocument* transform( indri::api::ParsedDocument* document ); 00048 00049 void setHandler( ObjectHandler<indri::api::ParsedDocument>& handler ); 00050 void handle( indri::api::ParsedDocument* document ); 00051 static bool _indri_kstem_loaded; 00052 }; 00053 } 00054 } 00055 00056 #endif // INDRI_KROVETZSTEMMERTRANSFORMATION_HPP 00057