On Fri, 5 May 2000, Gilles Detillieux wrote:
> According to Alexey Rodriguez:
> > I am releasing a patch for choosing boolean keywords from
> > configuration file. The attribute should look like:
> >
> > boolean_keywords: and or not
> >
> > If you don't put anything it doesn't matter what is the default
> > value. For example i use:
> >
> > boolean_keywords: y o no
> >
> > The error messages are still in english. Any suggestions are
> > welcome and i expect that i did not break anything. ;)
>
> The only problem I can see is if the user enters more than 3 strings
> in the boolean_keywords string list, it will overflow the String array.
> You should probably add a test in the loop to avoid this. E.g.:
>
> > + String boolean_keywords[3];
> > +
> > + void load_boolean_keywords()
> > + {
> > + String temp=config["boolean_keywords"];
> > + char *w=strtok(temp," \t");
> > + int i=0;
> > + while(w) {
>
> if (i<3) { // don't go out of bounds
>
> > + boolean_keywords[i]=w;
> > + boolean_keywords[i].lowercase();
>
> }
>
> > + w=strtok(NULL," \t");
> > + i++;
> > + }
> > + if(i!=3) {
> > + reportError("boolean_keywords is not correctly specified");
> > + }
> > + }
>
> --
> Gilles R. Detillieux E-mail: <[EMAIL PROTECTED]>
> Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil
> Dept. Physiology, U. of Manitoba Phone: (204)789-3766
> Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930
>
> ------------------------------------
> To unsubscribe from the htdig mailing list, send a message to
> [EMAIL PROTECTED]
> You will receive a message to confirm this.
>
Sending corrected patch, thanks Gilles
Alexey
diff -rc htdig-3.1.5/htcommon/defaults.cc tmp/htdig-3.1.5/htcommon/defaults.cc
*** htdig-3.1.5/htcommon/defaults.cc Fri May 5 11:59:52 2000
--- tmp/htdig-3.1.5/htcommon/defaults.cc Fri May 5 12:00:36 2000
***************
*** 37,42 ****
--- 37,43 ----
{"bad_extensions", ".wav .gz .z .sit .au .zip .tar .hqx
.exe .com .gif .jpg .jpeg .aiff .class .map .ram .tgz .bin .rpm .mpg .mov .avi"},
{"bad_querystr", ""},
{"bad_word_list", "${common_dir}/bad_words"},
+ {"boolean_keywords", "and or not"},
{"build_select_lists", ""},
{"case_sensitive", "true"},
{"common_url_parts", "http:// http://www. ftp:// ftp://ftp. /pub/
.html .htm .gif .jpg .jpeg /index.html /index.htm .com/ .com mailto:"},
***************
*** 167,170 ****
--- 168,175 ----
};
Configuration config;
+
+
+
+
diff -rc htdig-3.1.5/htsearch/htsearch.cc tmp/htdig-3.1.5/htsearch/htsearch.cc
*** htdig-3.1.5/htsearch/htsearch.cc Fri May 5 11:59:52 2000
--- tmp/htdig-3.1.5/htsearch/htsearch.cc Fri May 5 12:00:58 2000
***************
*** 48,53 ****
--- 48,78 ----
int minimum_word_length = 3;
+ // boolean keywords are loaded in this function
+ // they should be placed in this order:
+ // 0 1 2
+ // and or not
+
+ String boolean_keywords[3];
+
+ void load_boolean_keywords()
+ {
+ String temp=config["boolean_keywords"];
+ char *w=strtok(temp," \t");
+ int i=0;
+ while(w) {
+ if(i<3) {
+ boolean_keywords[i]=w;
+ boolean_keywords[i].lowercase();
+ }
+ w=strtok(NULL," \t");
+ i++;
+ }
+ if(i!=3) {
+ reportError("boolean_keywords is not correctly specified");
+ }
+ }
+
//*****************************************************************************
// int main()
//
***************
*** 202,207 ****
--- 227,235 ----
url_part_errors.get()));
Parser *parser = new Parser();
+
+ // Load boolean keywords from configuration
+ load_boolean_keywords();
//
// Parse the words to search for from the argument list.
***************
*** 305,315 ****
if (!ww->isHidden)
{
if (strcmp(ww->word, "&") == 0 && wasHidden == 0)
! logicalWords << " and ";
else if (strcmp(ww->word, "|") == 0 && wasHidden == 0)
! logicalWords << " or ";
else if (strcmp(ww->word, "!") == 0 && wasHidden == 0)
! logicalWords << " not ";
else if (wasHidden == 0)
{
logicalWords << ww->word;
--- 333,343 ----
if (!ww->isHidden)
{
if (strcmp(ww->word, "&") == 0 && wasHidden == 0)
! logicalWords << " " << boolean_keywords[0] << " ";
else if (strcmp(ww->word, "|") == 0 && wasHidden == 0)
! logicalWords << " " << boolean_keywords[1] << " ";
else if (strcmp(ww->word, "!") == 0 && wasHidden == 0)
! logicalWords << " " << boolean_keywords[2] << " ";
else if (wasHidden == 0)
{
logicalWords << ww->word;
***************
*** 409,423 ****
pos--;
word.lowercase();
! if (boolean && mystrcasecmp(word.get(), "and") == 0)
{
tempWords.Add(new WeightWord("&", -1.0));
}
! else if (boolean && mystrcasecmp(word.get(), "or") == 0)
{
tempWords.Add(new WeightWord("|", -1.0));
}
! else if (boolean && mystrcasecmp(word.get(), "not") == 0)
{
tempWords.Add(new WeightWord("!", -1.0));
}
--- 437,451 ----
pos--;
word.lowercase();
! if (boolean && mystrcasecmp(word.get(), boolean_keywords[0]) == 0)
{
tempWords.Add(new WeightWord("&", -1.0));
}
! else if (boolean && mystrcasecmp(word.get(), boolean_keywords[1]) ==
0)
{
tempWords.Add(new WeightWord("|", -1.0));
}
! else if (boolean && mystrcasecmp(word.get(), boolean_keywords[2]) ==
0)
{
tempWords.Add(new WeightWord("!", -1.0));
}
------------------------------------
To unsubscribe from the htdig mailing list, send a message to
[EMAIL PROTECTED]
You will receive a message to confirm this.