![]() |
|||
ParameterSet.javaGo to the documentation of this file.00001 /* 00002 * ParameterSet.java 00003 * 00004 * Copyright (C) 2003 Alain MENSEGUEN 00005 * www.net2map.org 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 package org.net2map.pov.server; 00022 00026 import java.io.*; 00027 00028 public class ParameterSet implements Serializable 00029 { 00030 public ParameterSet() 00031 { 00032 DEBUG = 3; 00033 setDBUser( "search" ); 00034 setDBPass( "search" ); 00035 setDBHost( "127.0.0.1" ); 00036 setDBName( "mnoGoSearch" ); 00037 setDBMode( "multi" ); 00038 setDBType( "pgsql"); 00039 setVarDir( "" ); 00040 setTrackQuery( false ); 00041 setCache( false ); 00042 setClones( true ); 00043 setLocalCharset( "" ); 00044 setIspellUsePrefixes( false ); 00045 setPhrase( false ); 00046 setStopwordFile( "" ); 00047 setStopwordTable( "" ); 00048 setMinWordLength( 1 ); 00049 setMaxWordLength( 32 ); 00050 setDBFormat( "3.0" ); 00051 setCrc32( "./crc32" ); 00052 sIspellMode = ""; 00053 } 00054 00055 public String getDBAddr() 00056 { 00057 return sDBAddr; 00058 } 00059 00060 public String getDBUser() 00061 { 00062 return sDBUser; 00063 } 00064 00065 public String getDBPass() 00066 { 00067 return sDBPass; 00068 } 00069 00070 public String getDBHost() 00071 { 00072 return sDBHost; 00073 } 00074 00075 public String getDBPort() 00076 { 00077 return sDBPort; 00078 } 00079 00080 public String getDBName() 00081 { 00082 return sDBName; 00083 } 00084 00085 public String getDBMode() 00086 { 00087 return sDBMode; 00088 } 00089 00090 public String getDBFormat() 00091 { 00092 return sDBFormat; 00093 } 00094 00095 public String getDBType() 00096 { 00097 return sDBType; 00098 } 00099 00100 public String getVarDir() 00101 { 00102 return sVarDir; 00103 } 00104 00105 public boolean getTrackQuery() 00106 { 00107 return bTrackQuery; 00108 } 00109 00110 public boolean getCache() 00111 { 00112 return bCache; 00113 } 00114 00115 public boolean getClones() 00116 { 00117 return bClones; 00118 } 00119 00120 public String getLocalCharset() 00121 { 00122 return sLocalCharset; 00123 } 00124 00125 public boolean getIspellUsePrefixes() 00126 { 00127 return bIspellUsePrefixes; 00128 } 00129 00130 public boolean getPhrase() 00131 { 00132 return bPhrase; 00133 } 00134 00135 public String getStopwordFile() 00136 { 00137 return sStopwordFile; 00138 } 00139 00140 public String getStopwordTable() 00141 { 00142 return sStopwordTable; 00143 } 00144 00145 public int getMinWordLength() 00146 { 00147 return nMinWordLength; 00148 } 00149 00150 public int getMaxWordLength() 00151 { 00152 return nMaxWordLength; 00153 } 00154 00155 private String[] getDictTable() 00156 { 00157 return dict_table; 00158 } 00159 00160 public String getIspellMode() 00161 { 00162 return sIspellMode; 00163 } 00164 00165 public String getCrc32() 00166 { 00167 return sCrc32; 00168 } 00169 00170 public String getCrcField() 00171 { 00172 return sCrcField; 00173 } 00174 00175 public String getCatField() 00176 { 00177 return sCatField; 00178 } 00179 00180 public String getLastModField() 00181 { 00182 return sLastModField; 00183 } 00184 00185 public void setDBAddr(String dbaddr) 00186 { 00187 sDBAddr = dbaddr; 00188 } 00189 00190 public void setDBUser(String dbuser) 00191 { 00192 sDBUser = dbuser; 00193 } 00194 00195 public void setDBPass(String dbpass) 00196 { 00197 sDBPass = dbpass; 00198 } 00199 00200 public void setDBHost(String dbhost) 00201 { 00202 sDBHost = dbhost; 00203 } 00204 00205 public void setDBPort(String dbport) 00206 { 00207 sDBPort = dbport; 00208 } 00209 00210 public void setDBName(String dbname) 00211 { 00212 sDBName = dbname; 00213 } 00214 00215 public void setDBType(String dbtype) 00216 { 00217 sDBType = dbtype; 00218 } 00219 00220 public void setDBFormat(String dbformat) 00221 { 00222 if ( ( dbformat != "3.0" ) && ( dbformat != "3.1" ) ) 00223 { 00224 dbformat = "3.0"; 00225 } 00226 00227 sDBFormat = dbformat; 00228 00229 if ( sDBFormat == "3.1" ) 00230 { 00231 sCatField = ",category"; 00232 } 00233 else 00234 { 00235 sCatField = ""; 00236 } 00237 00238 if ( sDBFormat == "3.1" ) 00239 { 00240 sLastModField = "url.last_mod_time"; 00241 } 00242 else 00243 { 00244 sLastModField = "url.last_modified"; 00245 } 00246 00247 sCrcField = "url.crc"; 00248 00249 if ( sDBFormat == "3.1" ) 00250 { 00251 sCrcField = "url.crc32"; 00252 } 00253 } 00254 00255 public void setDBMode( String dbmode ) 00256 { 00257 sDBMode = dbmode; 00258 00259 if ( DEBUG > 1 ) 00260 { 00261 System.out.println( "Database mode : " + sDBMode ); 00262 } 00263 00264 if ( sDBMode == "multi" ) 00265 { 00266 dict_table = dict_table1; 00267 } 00268 00269 if ( sDBMode == "crc-multi" ) 00270 { 00271 dict_table = dict_table2; 00272 } 00273 } 00274 00275 public void setVarDir( String vardir ) 00276 { 00277 sVarDir = vardir; 00278 } 00279 00280 public void setTrackQuery( boolean trackquery ) 00281 { 00282 bTrackQuery = trackquery; 00283 } 00284 00285 public void setCache( boolean cache ) 00286 { 00287 bCache = cache; 00288 } 00289 00290 public void setClones( boolean clones ) 00291 { 00292 bClones = clones; 00293 } 00294 00295 public void setLocalCharset( String localcharset ) 00296 { 00297 sLocalCharset = localcharset; 00298 } 00299 00300 public void setIspellUsePrefixes( boolean ispelluseprefixes ) 00301 { 00302 bIspellUsePrefixes = ispelluseprefixes; 00303 } 00304 00305 public void setPhrase( boolean phrase ) 00306 { 00307 bPhrase = phrase; 00308 } 00309 00310 public void setStopwordFile( String stopwordfile ) 00311 { 00312 sStopwordFile = stopwordfile; 00313 } 00314 00315 public void setStopwordTable( String stopwordtable ) 00316 { 00317 sStopwordTable = stopwordtable; 00318 } 00319 00320 public void setMinWordLength( int minwordlength ) 00321 { 00322 nMinWordLength = minwordlength; 00323 } 00324 00325 public void setMaxWordLength( int maxwordlength ) 00326 { 00327 nMaxWordLength = maxwordlength; 00328 } 00329 00330 public void setIspellMode( String ispellmode ) 00331 { 00332 sIspellMode = ispellmode; 00333 } 00334 00335 public void setCrc32( String Crc32 ) 00336 { 00337 sCrc32 = Crc32; 00338 } 00339 00340 public void setCrcField( String crcfield ) 00341 { 00342 sCrcField = crcfield; 00343 } 00344 00345 public void setCatField (String catfield ) 00346 { 00347 sCatField = catfield; 00348 } 00349 00350 public void setLastModField( String lastmodfield ) 00351 { 00352 sLastModField = lastmodfield; 00353 } 00354 00355 public String replace( String str, String toFind, String toUse ) 00356 { 00357 int n = 0; 00358 String result = str; 00359 00360 if (str != "" && toFind != "") 00361 { 00362 n = str.indexOf( toFind ); 00363 if ( n != -1 ) 00364 { 00365 result = str.substring( 0, n ) + toUse + str.substring( n + toFind.length(), str.length() ); 00366 } 00367 } 00368 00369 return result; 00370 } 00371 00372 /*Database parameters are to be used with SQL backend 00373 and do not matter for built-in text files support 00374 Format: <DBType>:[//[DBUser[:DBPass]@]DBHost[:DBPort]]/DBName/ 00375 DBAddr mysql://alain:alain@localhost/mnoGoSearch/*/ 00376 private String sDBAddr; 00377 private String sDBUser; 00378 private String sDBPass; 00379 private String sDBHost; 00380 private String sDBPort; 00381 private String sDBName; 00382 private String sDBFormat; 00383 private String sDBType; 00384 00385 /*Choose storage mode (see explanation in indexer.conf-dist): 00386 DBMode single 00387 DBMode multi 00388 DBMode crc 00389 DBMode crc-multi 00390 DBMode cache*/ 00391 private String sDBMode; 00392 00393 /*For cache mode and built-in database 00394 you may choose alternative working directory 00395 VarDir /usr/local/mnogosearch/var*/ 00396 private String sVarDir; 00397 00398 /*Query tracking facility*/ 00399 private boolean bTrackQuery; 00400 00401 /*Search result cache*/ 00402 private boolean bCache; 00403 00404 00405 /*Detect and show clones*/ 00406 private boolean bClones; 00407 00408 /*Local charset, use proper one: 00409 LocalCharset iso-8859-1 00410 LocalCharset iso-8859-2 00411 LocalCharset iso-8859-4 00412 LocalCharset iso-8859-5 00413 LocalCharset iso-8859-7 00414 LocalCharset iso-8859-8 00415 LocalCharset iso-8859-9 00416 LocalCharset iso-8859-13 00417 LocalCharset koi8-r 00418 LocalCharset windows-1250 00419 LocalCharset windows-1251 00420 LocalCharset windows-1253 00421 LocalCharset windows-1254 00422 LocalCharset windows-1255 00423 LocalCharset windows-1256 00424 LocalCharset windows-1257 00425 LocalCharset cp866*/ 00426 private String sLocalCharset; 00427 00428 /*IspellUsePrefixes 00429 If enabled, indexer will use ispell prefixes, not only suffixes*/ 00430 private boolean bIspellUsePrefixes; 00431 00432 /*Load ispell data from database: db*/ 00433 private String sIspellMode; 00434 /*or load ispell data from files: 00435 Affix en /usr/dict/en.aff 00436 Affix ru /usr/dict/ru.aff 00437 Spell en /usr/dict/en.dict 00438 Spell ru /usr/dict/ru.dict*/ 00439 00440 /*TRUE if index was built with phrase support*/ 00441 private boolean bPhrase; 00442 00443 /*Load stopwords from file*/ 00444 private String sStopwordFile; 00445 00446 /*Load stopwords from SQL table*/ 00447 private String sStopwordTable; 00448 00449 /*Word lengths*/ 00450 private int nMinWordLength; 00451 private int nMaxWordLength; 00452 00453 public int DEBUG; 00454 00455 private String[] dict_table; 00456 private String[] dict_table1 = {"dict2", "dict2", "dict2", "dict3", 00457 "dict4", "dict5", "dict6", "dict7", 00458 "dict8", "dict9", "dict10","dict11", 00459 "dict12","dict16","dict16","dict16", 00460 "dict16","dict32"}; 00461 00462 private String[] dict_table2 = {"ndict2", "ndict2", "ndict2", "ndict3", 00463 "ndict4", "ndict5", "ndict6", "ndict7", 00464 "ndict8", "ndict9", "ndict10","ndict11", 00465 "ndict12","ndict16","ndict16","ndict16", 00466 "ndict16","ndict32"}; 00467 private String sCrc32; 00468 private String sCrcField; 00469 private String sCatField; 00470 private String sLastModField; 00471 00473 public String getDictTab( String word ) 00474 { 00475 if ( word.length() > 16 ) 00476 { 00477 return getDictTable()[17]; 00478 } 00479 00480 return getDictTable()[word.length()]; 00481 } 00482 } |
|||
|
Accueil | Téléchargement | Manuel
| Doc. technique | Sources CVS |
Faq | Nous contacter
©2003 - All Rights Reserved |
|||