Changeset 12770
- Timestamp:
- 2006-09-18T14:32:31+12:00 (18 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/lucene_query.pl
r12656 r12770 44 44 { 45 45 my $full_indexdir = shift(@_); 46 my $fuzz y= shift(@_);46 my $fuzziness = shift(@_); 47 47 my $filter_string = shift(@_); 48 48 my $sort_field = shift(@_); … … 56 56 57 57 my $cmd = "| " . $java_lucene . " \"" . $full_indexdir . "\""; 58 if (defined($fuzz y)) {59 $cmd .= " -fuzz y";58 if (defined($fuzziness)) { 59 $cmd .= " -fuzziness " . $fuzziness; 60 60 } 61 61 if (defined($filter_string)) { … … 94 94 my $argc = scalar(@argv); 95 95 if ($argc == 0) { 96 print STDERR "Usage: $PROGNAME full-index-dir [query] [-fuzz y] [-filter filter_string] [-sort sort_field] [-dco AND|OR] [-startresults number -endresults number] [-out out_file]\n";96 print STDERR "Usage: $PROGNAME full-index-dir [query] [-fuzziness value] [-filter filter_string] [-sort sort_field] [-dco AND|OR] [-startresults number -endresults number] [-out out_file]\n"; 97 97 exit 1; 98 98 } … … 100 100 my $full_indexdir = shift(@argv); 101 101 my $query = undef; 102 my $fuzz y= undef;102 my $fuzziness = undef; 103 103 my $filter_string = undef; 104 104 my $sort_field = undef; … … 109 109 for (my $i = 0; $i < scalar(@argv); $i++) 110 110 { 111 if ($argv[$i] eq "-fuzzy") { 112 $fuzzy = 1; 111 if ($argv[$i] eq "-fuzziness") { 112 $i++; 113 $fuzziness = $argv[$i]; 113 114 } 114 115 elsif ($argv[$i] eq "-filter") { … … 141 142 } 142 143 143 open_java_lucene($full_indexdir, $fuzz y, $filter_string, $sort_field, $dco, $start_results, $end_results, $out_file);144 open_java_lucene($full_indexdir, $fuzziness, $filter_string, $sort_field, $dco, $start_results, $end_results, $out_file); 144 145 145 146 if (defined $query) { -
trunk/gsdl/src/colservr/lucenesearch.cpp
r12685 r12770 123 123 cmd += " -sort \"" + queryparams.sortfield + "\""; 124 124 } 125 if (queryparams.fuzzysearch) 126 { 127 cmd += " -fuzzy"; 128 } 125 if (!queryparams.fuzziness.empty()) { 126 cmd += " -fuzziness " + queryparams.fuzziness; 127 } 129 128 130 129 // New code to support configuration of the default conjuction operator -
trunk/gsdl/src/colservr/queryfilter.cpp
r12655 r12770 92 92 query.filterstring = filterOptions["FilterString"].defaultValue; // Lucene specific 93 93 query.sortfield = filterOptions["SortField"].defaultValue; // Lucene specific 94 query.fuzz ysearch = (filterOptions["FuzzySearch"].defaultValue == "true"); // Lucene specific94 query.fuzziness = filterOptions["Fuzziness"].defaultValue; // Lucene specific 95 95 query.maxnumeric = maxnumeric; 96 96 OptionValue_tarray::const_iterator options_here = request.filterOptions.begin(); … … 121 121 query.filterstring = filterOptions["FilterString"].defaultValue; // Lucene specific 122 122 query.sortfield = filterOptions["SortField"].defaultValue; // Lucene specific 123 query.fuzz ysearch = (filterOptions["FuzzySearch"].defaultValue == "true"); // Lucene specific123 query.fuzziness = filterOptions["Fuzziness"].defaultValue; // Lucene specific 124 124 query.maxnumeric = maxnumeric; 125 125 // "all", needed when combining queries where the document results are needed … … 158 158 } else if ((*options_here).name == "SortField") { 159 159 query.sortfield = (*options_here).value; 160 } else if ((*options_here).name == "Fuzz ySearch") {161 query.fuzz ysearch = ((*options_here).value == "true");160 } else if ((*options_here).name == "Fuzziness") { 161 query.fuzziness = (*options_here).value; 162 162 } else { 163 163 logout << text_t2ascii -
trunk/gsdl/src/colservr/queryinfo.cpp
r12655 r12770 49 49 filterstring.clear(); 50 50 sortfield.clear(); 51 fuzz ysearch = 0; // 0 = not fuzzy, 1 = fuzzy51 fuzziness.clear(); 52 52 startresults = 1; // all 53 53 endresults = 10; // all … … 71 71 filterstring = q.filterstring; 72 72 sortfield = q.sortfield; 73 fuzz ysearch = q.fuzzysearch;73 fuzziness = q.fuzziness; 74 74 startresults = q.startresults; 75 75 endresults = q.endresults; … … 94 94 (x.filterstring == y.filterstring) && 95 95 (x.sortfield == y.sortfield) && 96 (x.fuzz ysearch == y.fuzzysearch) &&96 (x.fuzziness == y.fuzziness) && 97 97 (x.startresults == y.startresults) && 98 98 (x.startresults == y.startresults)); … … 123 123 outs << " filterstring = \"" << q.filterstring << "\"\n"; 124 124 outs << " sortfield = \"" << q.sortfield << "\"\n"; 125 outs << " fuzz ysearch = \"" << q.fuzzysearch<< "\"\n";125 outs << " fuzziness = \"" << q.fuzziness << "\"\n"; 126 126 outs << " startresults = \"" << q.startresults << "\"\n"; 127 127 outs << " endresults = \"" << q.endresults << "\"\n"; -
trunk/gsdl/src/colservr/queryinfo.h
r12655 r12770 68 68 text_t filterstring; // Filter specified (currently only used by Lucene) 69 69 text_t sortfield; // Field to use for sorting result set (currently used by lucene) 70 int fuzzysearch; // Should search be fuzzy(only used by Lucene)70 text_t fuzziness; // Search fuzziness amount between 0.0 and 1.0 (only used by Lucene) 71 71 72 72 int startresults; -
trunk/gsdl/src/java/org/nzdl/gsdl/LuceneWrap/GS2LuceneQuery.java
r12656 r12770 44 44 { 45 45 if (args.length == 0) { 46 System.out.println("Usage: GS2LuceneQuery <index directory> [-fuzz y] [-filter filter_string] [-sort sort_field] [-dco AND|OR] [-startresults number -endresults number]");46 System.out.println("Usage: GS2LuceneQuery <index directory> [-fuzziness value] [-filter filter_string] [-sort sort_field] [-dco AND|OR] [-startresults number -endresults number]"); 47 47 return; 48 48 } … … 58 58 Sort sorter = new Sort(); 59 59 Filter filter = null; 60 boolean fuzzy = false;60 String fuzziness = null; 61 61 62 62 // Paging … … 86 86 default_conjuction_operator = args[i]; 87 87 } 88 if (args[i].equals("-fuzz y"))88 if (args[i].equals("-fuzziness")) 89 89 { 90 fuzzy = true; 90 i++; 91 fuzziness = args[i]; 91 92 } 92 93 if (args[i].equals("-startresults")) … … 133 134 query_including_stop_words = query_including_stop_words.rewrite(reader); 134 135 135 Query query = parseQuery(reader, query_parser, query_string, fuzz y);136 Query query = parseQuery(reader, query_parser, query_string, fuzziness); 136 137 query = query.rewrite(reader); 137 138 … … 271 272 272 273 273 private static Query parseQuery(IndexReader reader, QueryParser query_parser, String query_string, boolean fuzzy)274 private static Query parseQuery(IndexReader reader, QueryParser query_parser, String query_string, String fuzziness) 274 275 throws java.io.IOException, org.apache.lucene.queryParser.ParseException 275 276 { … … 304 305 // If this is a fuzzy search, then we need to add the fuzzy 305 306 // flag to each of the query terms 306 if (fuzz y&& query.toString().length() > 0)307 if (fuzziness != null && query.toString().length() > 0) 307 308 { 308 309 // Revert the query to a string … … 363 364 { 364 365 ///ystem.err.println("Yahoo! Found fuzzy term."); 365 mutable_query_string.insert(o, '~' );366 mutable_query_string.insert(o, '~' + fuzziness); 366 367 o++; 367 368 s = 0; // Reset … … 374 375 if (s == 3) 375 376 { 376 mutable_query_string.append('~' );377 mutable_query_string.append('~' + fuzziness); 377 378 } 378 379 // Reparse the query -
trunk/gsdl/src/recpt/queryaction.cpp
r12768 r12770 430 430 argsinfo.addarginfo (NULL, arg_ainfo); 431 431 432 // "fuzz y" controls whether the search is fuzzy logic or not433 // (only implemented for Lucene collection... umm.. ever).434 arg_ainfo.shortname = "fuzz y";435 arg_ainfo.longname = " is this search be fuzzy";436 arg_ainfo.multiplechar = false;437 arg_ainfo.defaultstatus = cgiarginfo::weak; 438 arg_ainfo.argdefault = " 0";432 // "fuzziness" controls how closely the search terms must match 433 // 1.0 = exact match, 0.1 = very inexact match (only implemented for Lucene) 434 arg_ainfo.shortname = "fuzziness"; 435 arg_ainfo.longname = "Lucene fuzziness value"; 436 arg_ainfo.multiplechar = true; 437 arg_ainfo.defaultstatus = cgiarginfo::weak; 438 arg_ainfo.argdefault = "1.0"; 439 439 arg_ainfo.savedarginfo = cgiarginfo::must; 440 440 argsinfo.addarginfo (NULL, arg_ainfo); -
trunk/gsdl/src/recpt/querytools.cpp
r12685 r12770 153 153 } 154 154 155 // sort field for lucene 156 option.name = "FuzzySearch"; 157 option.value = (args.getintarg("fuzzy")) ? "true" : "false"; 158 request.filterOptions.push_back (option); 155 if (!args["fuzziness"].empty()) { // fuzziness value for lucene 156 option.name = "Fuzziness"; 157 option.value = args["fuzziness"]; 158 request.filterOptions.push_back (option); 159 } 159 160 160 161 set_more_queryfilter_options (request, args); -
trunk/indexers/lucene-gs/src/org/greenstone/LuceneWrapper/GS2LuceneQuery.java
r12656 r12770 44 44 { 45 45 if (args.length == 0) { 46 System.out.println("Usage: GS2LuceneQuery <index directory> [-fuzz y] [-filter filter_string] [-sort sort_field] [-dco AND|OR] [-startresults number -endresults number]");46 System.out.println("Usage: GS2LuceneQuery <index directory> [-fuzziness value] [-filter filter_string] [-sort sort_field] [-dco AND|OR] [-startresults number -endresults number]"); 47 47 return; 48 48 } … … 58 58 Sort sorter = new Sort(); 59 59 Filter filter = null; 60 boolean fuzzy = false;60 String fuzziness = null; 61 61 62 62 // Paging … … 86 86 default_conjuction_operator = args[i]; 87 87 } 88 if (args[i].equals("-fuzz y"))88 if (args[i].equals("-fuzziness")) 89 89 { 90 fuzzy = true; 90 i++; 91 fuzziness = args[i]; 91 92 } 92 93 if (args[i].equals("-startresults")) … … 133 134 query_including_stop_words = query_including_stop_words.rewrite(reader); 134 135 135 Query query = parseQuery(reader, query_parser, query_string, fuzz y);136 Query query = parseQuery(reader, query_parser, query_string, fuzziness); 136 137 query = query.rewrite(reader); 137 138 … … 271 272 272 273 273 private static Query parseQuery(IndexReader reader, QueryParser query_parser, String query_string, boolean fuzzy)274 private static Query parseQuery(IndexReader reader, QueryParser query_parser, String query_string, String fuzziness) 274 275 throws java.io.IOException, org.apache.lucene.queryParser.ParseException 275 276 { … … 304 305 // If this is a fuzzy search, then we need to add the fuzzy 305 306 // flag to each of the query terms 306 if (fuzz y&& query.toString().length() > 0)307 if (fuzziness != null && query.toString().length() > 0) 307 308 { 308 309 // Revert the query to a string … … 363 364 { 364 365 ///ystem.err.println("Yahoo! Found fuzzy term."); 365 mutable_query_string.insert(o, '~' );366 mutable_query_string.insert(o, '~' + fuzziness); 366 367 o++; 367 368 s = 0; // Reset … … 374 375 if (s == 3) 375 376 { 376 mutable_query_string.append('~' );377 mutable_query_string.append('~' + fuzziness); 377 378 } 378 379 // Reparse the query
Note:
See TracChangeset
for help on using the changeset viewer.