source: main/trunk/greenstone2/runtime-src/src/colservr/phrasequeryfilter.cpp@ 21326

Last change on this file since 21326 was 15558, checked in by mdewsnip, 16 years ago

(Adding new DB support) Changed lots of "gdbm"s to "db"s, in preparation for adding new DB types.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/**********************************************************************
2 *
3 * phrasequeryfilter.cpp --
4 * Copyright (C) 1999 DigiLib Systems Limited, New Zealand
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#include "phrasequeryfilter.h"
27#include "queryinfo.h"
28
29#include "phrasesearch.h"
30
31
32
33// do aditional query processing
34void phrasequeryfilterclass::post_process (const queryparamclass &queryparams,
35 queryresultsclass &queryresults) {
36 bool results_shrunk = false;
37
38 // post-process the results if needed
39 if (queryresults.orgterms.size() > 1 && !queryresults.docs.docset.empty()) {
40 // get the long version of the index
41 text_t longindex;
42 indexmap.to2from (queryparams.index, longindex);
43
44 // process each of the matched documents
45 docresultmap::iterator docs_here = queryresults.docs.docset.begin();
46 docresultmap::iterator docs_end = queryresults.docs.docset.end();
47 while (docs_here != docs_end) {
48 if ((*docs_here).second.num_query_terms_matched == queryresults.orgterms.size() &&
49 OID_phrase_search (*(mgsearchclass *)textsearchptr, *db_ptr, queryparams.index,
50 queryparams.subcollection, queryparams.language,
51 longindex, queryparams.collection, queryresults.orgterms,
52 (*docs_here).second.docnum)) {
53 ++docs_here->second.num_phrase_match;
54 ++docs_here;
55
56 } else {
57 docresultmap::iterator this_doc_here = docs_here;
58 ++docs_here;
59 if (queryparams.match_mode == 1) {
60 // need to delete this element, there was no exact match
61 queryresults.docs.docset.erase(this_doc_here);
62 results_shrunk = true;
63 }
64 }
65 }
66 }
67
68 if (results_shrunk) queryresults.docs_matched = queryresults.docs.docset.size();
69}
70
71
72void phrasequeryfilterclass::sort_doc_results (const FilterRequest_t &/*request*/,
73 docresultsclass &docs) {
74 resultsorderer_t resultsorderer;
75 resultsorderer.compare_phrase_match = true;
76 resultsorderer.compare_terms_match = true;
77 resultsorderer.compare_doc_weight = true;
78 resultsorderer.docset = &(docs.docset);
79
80 // first get a list of document numbers
81 docs.docnum_order();
82
83 sort (docs.docorder.begin(), docs.docorder.end(), resultsorderer);
84}
Note: See TracBrowser for help on using the repository browser.