in reply to Re: CGI search script: Exclusion list
in thread CGI search script: Exclusion list

This really isn't very good advice. First, you have the procedure the wrong way around: normally, the stopword list is fairly short and is held in memory, while the "search-string" data can be really huge, and is processed a line at a time.

But your regex substitution is actually kind of insidious. The deletion of stop words needs to be anchored to word boundaries. If the stop word list included "me or and a", your approach would reduce the word "memoranda" to just "m".

In general, the best approach is: store the stop words as hash keys, read the input text and tokenize it into words (being careful to remove punctuation as well as whitespace), then for each word, if it exists as a hash key, skip it.

  • Comment on Re^2: CGI search script: Exclusion list