source: main/tags/2.13/gsdl/src/colservr/phrasequeryfilter.cpp@ 23898

Last change on this file since 23898 was 534, checked in by sjboddie, 25 years ago

added gpl notice

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 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 * $Id: phrasequeryfilter.cpp 534 1999-09-07 04:57:43Z sjboddie $
25 *
26 *********************************************************************/
27
28/*
29 $Log$
30 Revision 1.4 1999/09/07 04:57:23 sjboddie
31 added gpl notice
32
33 Revision 1.3 1999/08/31 22:44:38 rjmcnab
34 Fixed small bug.
35
36 Revision 1.2 1999/07/07 06:19:45 rjmcnab
37 Added ability to combine two or more independant queries.
38
39 Revision 1.1 1999/07/01 04:01:47 rjmcnab
40 Initial revision.
41
42
43 */
44
45
46#include "phrasequeryfilter.h"
47#include "queryinfo.h"
48
49#include "phrasesearch.h"
50
51
52
53// do aditional query processing
54void phrasequeryfilterclass::post_process (const queryparamclass &queryparams,
55 queryresultsclass &queryresults) {
56 bool results_shrunk = false;
57
58 // post-process the results if needed
59 if (queryresults.orgterms.size() > 1 && !queryresults.docs.docset.empty()) {
60 // get the long version of the index
61 text_t longindex;
62 indexmap.to2from (queryparams.index, longindex);
63
64 // process each of the matched documents
65 docresultmap::iterator docs_here = queryresults.docs.docset.begin();
66 docresultmap::iterator docs_end = queryresults.docs.docset.end();
67 while (docs_here != docs_end) {
68 if ((*docs_here).second.num_query_terms_matched == queryresults.orgterms.size() &&
69 OID_phrase_search (*mgsearchptr, *gdbmptr, queryparams.index,
70 queryparams.subcollection, queryparams.language,
71 longindex, queryparams.collection, queryresults.orgterms,
72 (*docs_here).second.docnum)) {
73 (*docs_here).second.num_phrase_match++;
74 docs_here++;
75
76 } else {
77 docresultmap::iterator this_doc_here = docs_here;
78 docs_here++;
79 if (queryparams.match_mode == 1) {
80 // need to delete this element, there was no exact match
81 queryresults.docs.docset.erase(this_doc_here);
82 results_shrunk = true;
83 }
84 }
85 }
86 }
87
88 if (results_shrunk) queryresults.docs_matched = queryresults.docs.docset.size();
89}
90
91
92void phrasequeryfilterclass::sort_doc_results (const FilterRequest_t &/*request*/,
93 docresultsclass &docs) {
94 resultsorderer_t resultsorderer;
95 resultsorderer.compare_phrase_match = true;
96 resultsorderer.compare_terms_match = true;
97 resultsorderer.compare_doc_weight = true;
98 resultsorderer.docset = &(docs.docset);
99
100 // first get a list of document numbers
101 docs.docnum_order();
102
103 sort (docs.docorder.begin(), docs.docorder.end(), resultsorderer);
104}
Note: See TracBrowser for help on using the repository browser.