source: trunk/gsdl/src/recpt/comtypes.cpp@ 7392

Last change on this file since 7392 was 6584, checked in by kjdon, 20 years ago

Fiddled around with segmenting for chinese text. Haven't changed how the
segmentation is done, or what character ranges are used.
But when its done is now controlled by the collect.cfg. There is a new
option, separate_cjk, values true or false, default false. Segmentation
is only done if this is set to true. This is passed as a global option to
all plugins by the import.pl script, so the user just needs to add it
once to the config file, not as an option to all plugins.
The queryaction uses this option too to determine whether or not to segment
the query.

  • Property svn:keywords set to Author Date Id Revision
File size: 7.1 KB
Line 
1/**********************************************************************
2 *
3 * comtypes.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
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 "comtypes.h"
27
28
29text_t get_comerror_string (comerror_t err) {
30 if (err == noError) return "no error";
31 else if (err == authenticationFailure) return "authentication failure";
32 else if (err == protocolError) return "protocol error";
33 else if (err == configurationError) return "configuration error";
34 else if (err == systemProblem) return "system problem";
35 else if (err == syntaxError) return "query syntax error";
36 return "unknown problem";
37}
38
39
40void ShortColInfo_t::clear() {
41 name.clear();
42 host.clear();
43 port = 0;
44}
45
46/*
47 isPublic now defaults to true most values are default
48 similar to a constructor in a class to make some initializations
49*/
50
51void ColInfoResponse_t::clear () {
52 shortInfo.clear();
53 isPublic=true;
54 isBeta=false;
55 isSegmented=false;
56 languages.erase(languages.begin(), languages.end());
57 ccsCols.erase(ccsCols.begin(), ccsCols.end());
58 buildDate=0;
59 buildType.clear();
60 searchTypes.erase(searchTypes.begin(), searchTypes.end());
61 numDocs=0;
62 numSections=0;
63 numWords=0;
64 numBytes=0;
65 format.erase(format.begin(), format.end());
66 building.erase(format.begin(), format.end());
67 httpdomain.clear();
68 httpprefix.clear();
69 receptionist.clear();
70
71 // Setting some authentication parameters use with
72 // various parts of the code.
73
74 authenticate.clear(); // turned off by default, individual collection authentication
75 auth_group.clear(); // turned off by default, authentication by groups method
76 public_documents.clear(); // turned off by default, allow access to these documents <list>
77 private_documents.clear(); // turned off by default, disallow access to these documents <list>
78
79}
80
81void InfoFiltersResponse_t::clear () {
82 filterNames.erase(filterNames.begin(), filterNames.end());
83}
84
85
86void InfoFilterOptionsRequest_t::clear () {
87 filterName.clear();
88}
89
90
91void FilterOption_t::clear () {
92 name.clear();
93 type = booleant;
94 repeatable = onePerQuery;
95 defaultValue.clear();
96 validValues.erase(validValues.begin(), validValues.end());
97}
98
99void FilterOption_t::check_defaultValue () {
100 text_tarray::iterator here, end;
101
102 // how the default is interpreted depends on the option type
103 switch (type) {
104 case booleant:
105 case enumeratedt: // has to be one of the validValues
106 here = validValues.begin ();
107 end = validValues.end ();
108 while (here != end) {
109 if (*here == defaultValue) return;
110 here++;
111 }
112
113 break;
114
115 case integert: // has to be in the validValues range
116 if ((validValues.size() >= 2) &&
117 (validValues[0].getint() <= defaultValue.getint()) &&
118 (validValues[1].getint() >= defaultValue.getint()))
119 return;
120 break;
121
122 case stringt: // any value is valid
123 return;
124 }
125
126 // did not find the defaultValue
127 if (validValues.empty()) defaultValue.clear();
128 else defaultValue = validValues[0];
129}
130
131
132bool operator==(const FilterOption_t &x, const FilterOption_t &y) {
133 return ((x.name == y.name) &&
134 (x.type == y.type) &&
135 (x.repeatable == y.repeatable) &&
136 (x.defaultValue == y.defaultValue) &&
137 (x.validValues == y.validValues));
138}
139
140bool operator<(const FilterOption_t &x, const FilterOption_t &y) {
141 return ((x.name < y.name) ||
142 ((x.name == y.name) &&
143 ((x.type < y.type) ||
144 ((x.type == y.type) &&
145 ((x.repeatable < y.repeatable) ||
146 ((x.repeatable == y.repeatable) &&
147 ((x.defaultValue < y.defaultValue) ||
148 ((x.defaultValue == y.defaultValue) &&
149 (x.validValues < y.validValues)))))))));
150}
151
152
153
154void InfoFilterOptionsResponse_t::clear () {
155 filterOptions.erase(filterOptions.begin(), filterOptions.end());
156}
157
158
159void OptionValue_t::clear () {
160 name.clear();
161 value.clear();
162}
163
164
165void FilterRequest_t::clear () {
166 filterName.clear();
167 filterOptions.erase(filterOptions.begin(), filterOptions.end());
168 docSet.erase(docSet.begin(), docSet.end());
169 filterResultOptions = 0;
170 requestParams.clear();
171 refParams.clear();
172 fields.erase(fields.begin(), fields.end());
173 getParents = false;
174}
175
176
177void TermInfo_t::clear () {
178 term.clear();
179 freq = 0;
180 matchTerms.erase (matchTerms.begin(), matchTerms.end());
181}
182
183
184void MetadataInfo_t::clear () {
185 params.clear();
186 isRef = false;
187 values.erase(values.begin(), values.end());
188 if (parent != NULL) {
189 delete parent;
190 parent = NULL;
191 }
192}
193
194MetadataInfo_t::MetadataInfo_t () {parent=NULL;clear();}
195
196// copy constructor
197MetadataInfo_t::MetadataInfo_t (const MetadataInfo_t &x) {
198 params = x.params;
199 isRef = x.isRef;
200 values = x.values;
201 if (x.parent == NULL) parent = NULL;
202 else {
203 parent = new MetadataInfo_t ();
204 *parent = *(x.parent);
205 }
206}
207
208MetadataInfo_t::~MetadataInfo_t () {
209 if (parent != NULL) {
210 delete parent;
211 parent = NULL;
212 }
213}
214
215MetadataInfo_t &MetadataInfo_t::operator=(const MetadataInfo_t &x) {
216 if (&x != this) {
217 params = x.params;
218 isRef = x.isRef;
219 values = x.values;
220 if (x.parent == NULL) parent = NULL;
221 else {
222 parent = new MetadataInfo_t ();
223 *parent = *(x.parent);
224 }
225 }
226 return *this;
227}
228
229void ResultDocInfo_t::clear () {
230 OID.clear ();
231 ranking = 0;
232 result_num = 0;
233 num_terms_matched = 0;
234 num_phrase_match = 0;
235 docFreq.erase(docFreq.begin(), docFreq.end());
236 metadata.erase(metadata.begin(), metadata.end());
237 classifier_metadata_type.erase(classifier_metadata_type.begin(),
238 classifier_metadata_type.end());
239 classifier_metadata_offset = 0;
240
241}
242
243ResultDocInfo_t &ResultDocInfo_t::operator=(const ResultDocInfo_t &x) {
244 OID = x.OID;
245 ranking = x.ranking;
246 result_num = x.result_num;
247 num_terms_matched = x.num_terms_matched;
248 num_phrase_match = x.num_phrase_match;
249 docFreq = x.docFreq;
250 metadata = x.metadata;
251 return *this;
252}
253
254void FilterResponse_t::clear () {
255 numDocs = 0;
256 isApprox = Exact;
257 termInfo.erase (termInfo.begin(), termInfo.end());
258 docInfo.erase (docInfo.begin(), docInfo.end());
259}
260
261FilterResponse_t &FilterResponse_t::operator=(const FilterResponse_t &x) {
262 numDocs = x.numDocs;
263 isApprox = x.isApprox;
264 termInfo = x.termInfo;
265 docInfo = x.docInfo;
266 return *this;
267}
268
269void DocumentRequest_t::clear () {
270 OID.clear();
271 docType.clear();
272 docFormat.clear();
273}
274
275void DocumentResponse_t::clear () {
276 doc.clear();
277}
Note: See TracBrowser for help on using the repository browser.