Ghostofmacbeth opened this issue on Mar 13, 2003 ยท 8 posts
_dodger posted Sat, 15 March 2003 at 6:10 AM
If you'd like a little suggestion, I can tell you how to get google/yahoo type parsing functionality... First, extract everything in quotes from the string and put them into an array In perl, this would work like:
while ($query =~ s/[+-]?"[^"]*"//) {
push @quoted, $1;
}
Then split the remaining query on whitespace: @unquoted =
split " ", $query;
Then combine the arrays: @everything = (@quoted, @unquoted);
Then iterate through the combined array and sort based on requirement prefix, removing the prefix:
for (@everything) {
if (s/^-//) {
push @restricted, $;
next;
}
if (s/^+//) {
push @required, $;
}
push @terms, $_;
}
Now you have an array called restricted containing terms it cannot have, an array called required containing terms ir must have, and an array called terms containing things it should but doesn't have to have. You can build a query using these arrays, using NOT LIKEs for the restricted array, and LIKEs for the required and terms arrays, with the terms ORed together and the required and restricted ANDed together.