FirteX-高性能全文索引和检索平台API Documentation |
00001 // 00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 00003 // All rights reserved. 00004 // This file is part of FirteX (www.firtex.org) 00005 // 00006 // Use of the FirteX is subject to the terms of the software license set forth in 00007 // the LICENSE file included with this software, and also available at 00008 // http://www.firtex.org/license.html 00009 // 00010 // Author : 郭瑞杰(GuoRuijie) 00011 // Email : ruijieguo@software.ict.ac.cn,ruijieguo@gmail.com 00012 // Created : 2006/8/3 00013 // 00014 #ifndef _ARGUMENT_H 00015 #define _ARGUMENT_H 00016 00017 #if _MSC_VER > 1000 00018 #pragma once 00019 #endif // _MSC_VER > 1000 00020 00021 #include "StdHeader.h" 00022 #include "../document/Field.h" 00023 #include <vector> 00024 using namespace std; 00025 using namespace firtex::document; 00026 00027 namespace firtex 00028 { 00029 namespace utility 00030 { 00031 class CXMLElement; 00032 class CArgument 00033 { 00034 public: 00035 CArgument(void); 00036 ~CArgument(void); 00037 protected: 00038 typedef vector<pair<tstring,TermVector_> > termvector_array; 00039 public: 00074 void parseArg(const tchar* argFile); 00075 00081 void saveArg(const tchar* argFile = NULL); 00082 00087 const tstring& getFileName(){return m_filename;} 00088 public: 00089 struct scollection 00090 { 00091 tstring identifier; 00092 struct smodifieddate 00093 { 00094 tstring field; 00095 bool store; 00096 bool index; 00097 }modifieddate; 00098 }collection; 00099 00100 struct sparser 00101 { 00102 tstring identifier; 00103 termvector_array termvectors; 00104 }parser; 00105 00106 struct sanalyzer 00107 { 00108 tstring identifier; 00109 tstring stopwordFile; 00110 }analyzer; 00111 00112 struct sindex 00113 { 00114 tstring srcfile; 00115 tstring dstindex; 00116 bool append; 00117 tstring mergemode; 00118 int32_t maxIndexTerms; 00119 int64_t memory; 00120 }index; 00121 00122 struct sindexmerger 00123 { 00124 int32_t mergeFactor; 00125 int32_t maxIndexBarrels; 00126 }indexmerger; 00127 00128 struct slog 00129 { 00130 tstring level; 00131 00132 }log; 00133 00134 public: 00138 void replaceStdArg(); 00139 00143 void restoreStdArg(); 00144 00148 void resetArg(); 00149 protected: 00150 //保存标准参数以供恢复 00151 struct sstd_analyzer 00152 { 00153 tstring stopwordFile; 00154 }std_analyzer; 00155 00156 struct sstd_index 00157 { 00158 int32_t maxIndexTerms; 00159 int64_t memory; 00160 }std_index; 00161 00162 struct sstd_indexmerger 00163 { 00164 int32_t mergeFactor; 00165 int32_t maxIndexBarrels; 00166 }std_indexmerger ; 00167 protected: 00168 void add(const tstring& sName, int64_t* pInt64, int64_t nDefault); 00169 void add(const tstring& sName, int32_t* pInt32, int32_t nDefault); 00170 void add(const tstring& sName, double* pFloat, double nDefault); 00171 void add(const tstring& sName, tstring* pString, const tstring& pszDefault); 00172 void add(const tstring& sName, bool* pBool, bool bDefault = true); 00173 void add(const tstring& sName, termvector_array* pTermVector); 00174 00175 00176 protected: 00177 class CArgumentItem 00178 { 00179 public: 00180 CArgumentItem(const tstring& sName); 00181 CArgumentItem(const tstring& sName, int64_t* pInt64,int32_t* pInt32,double* pFloat, tstring* pString,bool* pBool); 00182 virtual void load(CXMLElement* pXML); 00183 virtual void save(CXMLElement* pXML); 00184 public: 00185 tstring m_sName; 00186 int32_t* m_pInt32; 00187 int64_t* m_pInt64; 00188 double* m_pFloat; 00189 tstring* m_pString; 00190 bool* m_pBool; 00191 }; 00192 class CTermVectorFieldsItem : public CArgumentItem 00193 { 00194 public: 00195 CTermVectorFieldsItem(const tstring& sName,termvector_array* tvs); 00196 virtual void load(CXMLElement* pXML); 00197 virtual void save(CXMLElement* pXML); 00198 public: 00199 termvector_array* m_pTermVectors; 00200 }; 00201 protected: 00202 vector<CArgumentItem*> m_items; 00203 tstring m_filename; 00204 }; 00205 } 00206 } 00207 00208 #endif
http://www.firtex.org http://www.sourceforge.net/projects/firtex