Re: [htdig] Boolean error combining "keywords" with "words"


Subject: Re: [htdig] Boolean error combining "keywords" with "words"
From: Gilles Detillieux (grdetil@scrc.umanitoba.ca)
Date: Fri Mar 17 2000 - 12:21:53 PST


According to C.W.J. Beenakker:
> PROBLEM:
>
> combining a non-empty "keywords" field with an empty "words" field results
> in a Boolean error from htsearch; is there any way around this?
>
> BACKGROUND:
>
> the database contains a listing of publications, and I'm using the
> "keywords" field to select special topics and the "words" field to
> narrow the search to specific authors or words in the title; I would
> like to make it possible to retrieve all papers on a given topic by
> just leaving the "words" field empty, but that doesn't seem to work...

Please try out the following patch. It should prevent the addition of
parentheses to the boolean expression when there are no search words,
to avoid the syntax error.

At the same time, it adds an "any_keywords" attribute which, if set to
true, will "or" together all words in the keywords field, instead of
and'ing them together, so that any one of the keywords will be enough
for a match. This may not be what you want, but it was something that
Kevin Quinn and I discussed last summer, and I never did get the patch
into the 3.1.x series. This new patch should solve both problems.

*** htsearch/htsearch.cc.nowords Tue Feb 15 16:17:13 2000
--- htsearch/htsearch.cc Fri Mar 17 14:02:54 2000
*************** htsearch(char *wordfile, List &searchWor
*** 660,672 ****
  void
  addRequiredWords(List &searchWords, StringList &requiredWords)
  {
! searchWords.Insert(new WeightWord("(", -1.0), 0);
! searchWords.Add(new WeightWord(")", -1.0));
!
! for (int i = 0; i < requiredWords.Count(); i++)
      {
          searchWords.Add(new WeightWord("&", -1.0));
! searchWords.Add(new WeightWord(requiredWords[i], 1.0));
      }
  }
  
--- 660,691 ----
  void
  addRequiredWords(List &searchWords, StringList &requiredWords)
  {
! static int any_keywords = config.Boolean("any_keywords", 0);
! if (requiredWords.Count() == 0)
! return;
! if (searchWords.Count() > 0)
      {
+ searchWords.Insert(new WeightWord("(", -1.0), 0);
+ searchWords.Add(new WeightWord(")", -1.0));
          searchWords.Add(new WeightWord("&", -1.0));
! }
! if (requiredWords.Count() == 1)
! {
! searchWords.Add(new WeightWord(requiredWords[0], 1.0));
! }
! else
! {
! searchWords.Add(new WeightWord("(", -1.0));
! searchWords.Add(new WeightWord(requiredWords[0], 1.0));
! for (int i = 1; i < requiredWords.Count(); i++)
! {
! if (any_keywords)
! searchWords.Add(new WeightWord("|", -1.0));
! else
! searchWords.Add(new WeightWord("&", -1.0));
! searchWords.Add(new WeightWord(requiredWords[i], 1.0));
! }
! searchWords.Add(new WeightWord(")", -1.0));
      }
  }
  

-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
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 htdig-unsubscribe@htdig.org You will receive a message to confirm this.



This archive was generated by hypermail 2b28 : Fri Mar 17 2000 - 11:19:33 PST